A generic error occurred in GDI+
I get this error in my asp.net site when I try to resize images:
A generic error occurred in GDI+
This is the code that gives the error:
Bitmap bitmap = new Bitmap(image, width, height);
Graphics graphicsImage = Graphics.FromImage(bitmap);
graphicsImage.SmoothingMode = SmoothingMode.HighQuality;
graphicsImage.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphicsImage.DrawImage(image, 0, 0, width, height);
//Get codecs
ImageCodecInfo[] icf = ImageCodecInfo.GetImageEncoders();
EncoderParameters encps = new EncoderParameters( 1 );
EncoderParameter encp = new EncoderParameter( Encoder.Quality, (long) 100 );
//Set quality
encps.Param[0] = encp;
bitmap.Save(fullfilename, icf[1], encps); //THIS IS THE LINE THAT GIVES THE ERROR
Any of you know what that means?
Status:
Open Feb 02, 2009 - 02:56 AM
gdi, Websites
1answer
Answer
Feb 02, 2009 - 03:24 AM
Apparently this not very helpful error message is due two either:
* The account the process is running as does not have permission to write to the target directory. Fix your permissions.
* The target directory does not exist.
In my case I added the ASPNET-user to the folders permissions and gave it access to modify and that solved the issue. (right click on the folder, choose the security tab in Windows XP)
Answer this question
Share Your Own Experience & Expertise
We look to ensure that every question is answered by the best people with relevant expertise and experience, the best answers include multiple perspectives. Do you have relevant expertise or experience to contribute your answer to any of these commonly asked questions?
Add New Comment