-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Corrupted JPEG does not result in visible error code #169
Comments
|
Yup. Notably, the behavior for this image varies by library: djpeg prints out a warning but will try to save a full-sized (with lots of grey) image. The python bindings for libjpegturbo throw an exception. Python PIL silently accepts it. Chrome will render it with lots of blank grey. The go standard library jpeg decoder returns an error trying to parse it ('invalid JPEG format: missing 0xff00 sequence'). rust-mozjpeg prints a warning to stderr that the programmer can't capture. :) It'd be nice to be able to select those behaviors or get access to a warning so as to be able to choose whether to be strict (as one might for my usecase, validating that a good image was supplied), or lenient (as one might for a browser or image viewer). |
One way forward might be to set a flag in the decoder before attempting to decode the file. If the flag is set, you get an error and no image, if it's unset, you get an image with gray areas and no indication of an error. |
That'd be a nice solution. |
Nevermind, I forgot how enums work smh. Just to throw it in: the error could in theory contain the partially decoded image. |
This image is corrupt and will not decode in most image decoders (convert; opencv imread), but does not produce a decoding error in jpeg-decoder. Whether this is a problem is debatable, of course - for an image viewer it's good to be able to display the partial, corrupted image - but it's also nice for a library to be able to report that there's a glitch.
A simple program to validate the lack of error:
Which, when run, produces:
The text was updated successfully, but these errors were encountered: