Skip to content
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

How to handle faulty jpgs? #241

Open
oqpvc opened this issue Nov 5, 2024 · 2 comments
Open

How to handle faulty jpgs? #241

oqpvc opened this issue Nov 5, 2024 · 2 comments

Comments

@oqpvc
Copy link

oqpvc commented Nov 5, 2024

Hi there!
I am trying to deal with JPG files that seem to be faulty, notably for images like the one attached which fails with

(DecodingError { format: Exact(Jpeg), underlying: Some("Unknown marker 0xFF7F") }

Other image processing tools like imagemagick can handle the image just fine, and a simple convert faulty.jpg notfaulty.jpg fixes the issue, but I am wondering if there is a way I can deal with this type of image directly anyways.

For context, the images are generated by a scanner when scanning to pdf. When I use the pdf crate to iterate over the images and try to use the image crate to make them accessible, I get the error above. Digging deeper, image uses zune to decode the image and when I use zune directly to decode this image, I get the same error, so that's why I'm asking here.

Roughly speaking I'm encountering this error at around 60% of images scanned with that scanner, always with a "Unknown marker 0xFF??" error where the last byte seems random to me.

If you have any idea how I could decode those image straight within rust anyways, that would be greatly appreciated.
fail

@oqpvc
Copy link
Author

oqpvc commented Nov 5, 2024

This is using zune-jpeg 0.4.13 btw.

@etemesi254
Copy link
Owner

JPEG markers are https://www.disktuna.com/list-of-jpeg-markers/ so 0xff7f is not there,

Let me investigate will get back to you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants