Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8889435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:15:44+00:00 2026-06-14T22:15:44+00:00

I’m doing some simple image resizing and rotation in an ASP.NET MVC 4 project,

  • 0

I’m doing some simple image resizing and rotation in an ASP.NET MVC 4 project, using the ImageResizer library. The problem is that when I use it to process 32-bpp CMYK JPEG files, it fails with an ArgumentException, but only on my (Windows Server 2008 R2) server – it works fine on my (Windows Vista) laptop.

The JPEG files in question aren’t too large (700×500) or otherwise non-standard – all web browsers and Paint can open them just fine, even on the server in question itself. The JPEGs have been generated using ImageMagick, and everything works fine if I ask ImageMagick to use an RGB colorspace (-colorspace sRGB.)

The weird thing is, just resizing the image works fine in all cases, but it fails if I try to resize and rotate the image on the server.

It looks like some lower-level Win32 or GDI+ function call is what’s failing here – here’s the relevant part of the stack trace:

[ArgumentException: Parameter is not valid.]
   System.Drawing.Graphics.CheckErrorStatus(Int32 status) +1621285
   System.Drawing.Graphics.DrawImage(Image image, PointF[] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, Int32 callbackData) +727
   System.Drawing.Graphics.DrawImage(Image image, PointF[] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr) +73
   ImageResizer.ImageBuilder.RenderImage(ImageState s) +763
   ImageResizer.ImageBuilder.Render(ImageState s) +174
   ImageResizer.ImageBuilder.Process(ImageState s) +105
   ImageResizer.ImageBuilder.buildToBitmap(Bitmap source, ResizeSettings settings, Boolean transparencySupported) +276
   ImageResizer.ImageBuilder.buildToStream(Bitmap source, Stream dest, ResizeSettings settings) +149
   ImageResizer.ImageBuilder.BuildJob(ImageJob job) +940
   ImageResizer.ImageBuilder.Build(ImageJob job) +223

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:15:45+00:00Added an answer on June 14, 2026 at 10:15 pm

    After some more research and testing, I’ve found that the problem occurs only if the Bitmap.RotateFlip method has been called on the source bitmap, before it is drawn onto a target bitmap for cropping and resizing.

    I ended up having to re-write the code using plain old System.Drawing myself, because there is no way to change the behavior of the ImageResizer library. Specifically, I wrote my own rotation function, which uses a transformation matrix to do the same thing.

        private Bitmap RotateImage(Bitmap source, float angle)
        {
            if (angle == 0) return (Bitmap)source.Clone();
    
            Bitmap target;
            using (GraphicsPath path = new GraphicsPath())
            using (Matrix matrix = new Matrix())
            {
                path.AddRectangle(new RectangleF(0.0f, 0.0f, source.Width, source.Height));
                matrix.Rotate(angle);
                RectangleF rect = path.GetBounds(matrix);
    
                target = new Bitmap((int)Math.Round(rect.Width), (int)Math.Round(rect.Height));
                target.SetResolution(source.HorizontalResolution, source.VerticalResolution);
    
                using (Graphics g = Graphics.FromImage(target))
                {
                    g.TranslateTransform(-rect.X, -rect.Y);
                    g.RotateTransform(angle);
                    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    g.DrawImageUnscaled(source, 0, 0);
                }
            }
            return target;
        }
    

    I would have wanted to set the PixelFormat of the new Bitmap to the one from the source – but doing so throws weird GDI+ “Out of memory” errors on encountering the CMYK JPEG files in question. This makes me wonder if this odd behavior is linked to this GDI+ bug/quirk that returns different ImageFlags and PixelFormat values on Windows 7/Server 2008 R2 and Windows Vista/Server 2008.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I am doing a simple coin flipping experiment for class that involves flipping a
I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.