Last post Apr 07, 2011 03:53 AM by Rapido_XS
Apr 07, 2011 03:53 AM|Rapido_XS|LINK
Yesterday after doing a profile picture upload for client, I found that all the thumbnails that where wrong, the upload process, resize process, and saving was working fine with all other images except the supplied images from the client. After doing a bit
of research I discovered that .JPG files actually embed a thumbnail in itself. The code I was calling to save the thumbnail was;
Dim oDrawingObject As System.Drawing.Image.GetThumbnailImageAbort
Dim oThumb As System.Drawing.Image = oImg.GetThumbnailImage(maxWidth, maxHeight, oDrawingObject, New System.IntPtr())
The get GetThumbnailImage - as I discovered - either get an
existing embedded thumbnail and resizes it to the give dimensions, or creates a new thumbnail with the given dimensions, and this is where the problem came in.
When cropping a .JPG image from some devices, the device will save the original image, or even other image as a embedded thumbnail, which was later picked up by my code and saved incorrectly.
My solution was to resave the images from another program, and re-upload. There are also other ways of creating thumbnails that you can use to avoid this problem, but I hope by reading this you'll avoid the frustrations I had under gone finding this problem.