Monthly Archives: March 2011

Parameter is not valid. GDI exception

I was getting this exception while working with the GDI images in
My requirement was to upload the image from client then resize it and display.

The code was working fine on local development machine, but on production server it was throwing “Parameter is not valid” exception.

The general cause of this is that non-availability of resources required to generate a valid image file.

In my case the reason was that the destination folder was having read-only permissions, which was causing the code to hault while saving the processed image back to server.

For the resources I read during this issue, I found out some more reasons, these can be following:
1) Invalid source image path passed to the Drawing/Image/Bitmap object.
2) Invalid destination image path passed to the Drawing/Image/Bitmap object.
3) Corrupted/incomplete byte array.
4) Disposing of Source object before completing generation of new Image.
5) Folder write permissions while saving the new file.