0

I need to be able to validate if a JPEG image is valid and not corrupted. This is not the same as question 210650 which just asks wants to validate that it is, in fact, a JPEG image. Loading from Image with validation eg:

var testJpg = Bitmap.FromStream(filename, useEmbeddedColorManagement, validateData); 

will not throw an exception for clipped images. Currently our solution is to try to open the file an external GD script and parse for any errors thrown from gdImageCreateFromJpeg.

gdImagePtr im; im = gdImageCreateFromJpeg(testFile); fclose(in); 

But there has to be some .Net code somewhere that validates that a JPEG is not only valid, but contains the complete image?

2 Answers 2

2

Taking JPEG reference structure from Wikipedia, maybe you can look for EOI byte from the stream?

Sign up to request clarification or add additional context in comments.

Comments

0

There is the pnetlib that provides an interop to jpeglib using c#, once you have that you can validate whatever you want.
You can try to use thier JpegReader, maybe it will give you an error out of the box.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.