Bad Image Finder Updated….

I’ve updated my earlier post about “How to find bad JPEG files in a directory – via Delphi (Source Code)“. It now includes a routine to do extra corruption checking if the image is a JPEG. The problem is that I don’t fully see/agree with the logic in this routine… but it seems to work better the person I wrote it for…. I just need some non-artificially corrupted JPEG files to test it on…

Anyway, see if you can make better sense of this…
while (Cardinal(pB) < pE) do begin if (pB^ < $E1) then begin Result := TRUE; Break; end else begin inc(pB); if (pB^ >= $E1)
then begin
if (pB^ >= $E1)
then begin
Result := TRUE;
inc(pB, 16);
end; [/delphi]

It goes backwards through the last line of the image and checks to see if the color (I believe) is less than the constant $E1. If it is, then result is changed from FALSE to TRUE and the routine exits with IsValidJPEG returning TRUE. Otherwise, if all the pixels in that line have a color greater than or equal too $E1 (labeled suspect blue),then the result remains FALSE and IsValidJPEG returns false…

So… basically it makes sure that there’s at least one valid colored pixel on the line and then it is assumed the jpeg is valid? That seems kindof sketchy to me… but if it works…

Any thoughts?

One Comment

Add a Comment

Your email address will not be published. Required fields are marked *