Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A null reference or invalid value was found [GDI+ status: InvalidParameter]

I am running an MVC3 app on Mono/linux and everything is working fine with the exception of an image upload utility. Whenever an image upload is attempted i get the Invalid Parameter error from within the method below:

    System.Drawing.GDIPlus.CheckStatus(status As Status) (unknown file): N 00339
    System.Drawing.Bitmap.SetResolution(xDpi As Single, yDpi As Single)

I've googled this error extensively and have found that the Invalid parameter error can often be misleading, and could fire if for example there was an error with the upload itself, or if the image was not fully read. This runs fine on IIS/Windows, but I've not been able to get it to work in Mono.

Apache2 Mono 2.10.8.1

Am i missing something simple or do i need to find a different way to handle image manipulation for mono?

like image 889
b0redom Avatar asked Dec 04 '25 15:12

b0redom


1 Answers

After doing quite a bit of testing, I was able to determine the root of my error. I was attempting to use the Image.HorizontalResolution and Image.VerticalResolution properties for Bitmap.Resolution . While these properties were set on the initial upload (where the file is read into a stream from the tmp directory), when i posted back with the base64 encoded string of the image itself, it appears these values were lost somehow. Because of this the SetResolution method failed.

For whatever reason i do not have this issue on IIS/Windows, the properties exist in both circumstances.

like image 63
b0redom Avatar answered Dec 06 '25 07:12

b0redom