I need to be able to check if the JPEG image is valid and not damaged. This is not the same as question 210650 , which simply asks to verify that it is, in fact, a JPEG image. Download from a confirmation image, for example:
var testJpg = Bitmap.FromStream(filename, useEmbeddedColorManagement, validateData);
will not throw an exception for cropped images. Currently, our solution is to try to open the file with an external GD script and analyze any errors that occurred from gdImageCreateFromJpeg.
gdImagePtr im; im = gdImageCreateFromJpeg(testFile); fclose(in);
But somewhere there should be some kind of .Net code that checks that JPEG is not only valid, but contains a complete image?
source share