-
-
Notifications
You must be signed in to change notification settings - Fork 842
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
Progressive jpeg with missing EOI marker throws EOFException #18
Comments
From @dlemstra on October 31, 2016 13:7 Can you add a link to the original jpg file? Github changed it into a PNG file. Is this the correct link: https://yooocanlive.azureedge.net/images/98bc0f36fcc4444e9889e152aa4ceb5d? And can you move your issue to the new repo: https://github.com/JimBobSquarePants/ImageSharp? The Core branch has been renamed. |
From @gdoron on October 31, 2016 13:14 @dlemstra Thanks! |
From @gdoron on October 31, 2016 13:19 BTW, in case you delete go to the link and read the story, |
@gdoron Great story, really heart-warming! 😄 I'm going to move this issue over to the correct repo as I have moved everything. We can continue the discussion there. |
Ok, @gdoron, I used jpegsnoop to analyse the image and it is technically corrupt as it's missing an EOI (End Of Image) marker. Theoretically it would still be possible to decode the image (Windows can) by calculating the number of expected MCU's (Minimum Coded Unit) if we are able to read the height and the width from the image header and stopping decoding once we have reached that value. Typically those are 8x8 units but can also be 16x8 or 16x16 depending on the subsampling. More info on MCU's can be found here It's not going to be easy to fix but I'll give it my best shot. |
Thanks James! |
@gdoron Whatever originally encoded the image probably has a bug. Or maybe even something has happened during file copy in some instance. It happens often enough. |
Yeah, we are getting many images like that lately... 😢 |
@JoepDiskTuna Welcome to GitHub...! 🎆 (it says you joined today). |
Ah, ok. I understand. I was just looking into JPG corruption and errors and all that and that's how Google got me here. In the end, the file was 'corrupt'. Just minor of course. Just check start and end markers for a start would be a good thing. But I don't have to tell you that. |
@JimBobSquarePants I have some time in the near future, I'm going to see if I can figure out how to bypass this. I'll keep you updated here; I assume you want to close #83 as a dupe. |
Great @vaindil! It's our top 1 bug on our website... 👍 👍 👍 |
This probably isn't ideal, but for the moment I can work around it like this: try
{
var imageTest = new Image(stream);
}
catch
{
stream.Seek(-2, SeekOrigin.End);
stream.WriteByte(0xff);
stream.WriteByte(0xd9);
}
stream.Seek(0, SeekOrigin.Begin);
var image = new Image(stream); |
Yeah that's nasty! We should have an MCU count in the decoder, working out whether to throw should be a case of checking against that count. If you could have a look that would be awesome. I would suggest looking at the source code for JpegSnoop on GitHub, that can detect missing EOI markers, warn and successfully decode them. |
I spent a good amount of time looking over it, and I cannot for the life of me figure out how to properly get the correct location of the EOI marker. I found a ton of resources but can't find a definitive way to get the info of where the file should end. :/ |
No worries, thanks for trying. It's on my list of thinks to work through so will get it done eventually. |
renaming to make the 2 issues different as one seems to be more easily fixable then the other. |
@gdoron I just merged a fix for none-progressive jpegs... updating to the latest |
@gdoron It seems we managed to fix this.
I would be very happy if you could provide some feedback about the situation with your inputs based on our latest build! 😄 |
I'll upload a new version of our application tomorrow with the latest build and let you know. Thank you all! |
@antonfirsov So far it's cool 👍 |
Cross target netstandard2.0
Cross target netstandard2.0
From @gdoron on October 31, 2016 12:57
Hi James @JimBobSquarePants,
This specific image:
fails when trying to load it.
Stacktrace:
Any clue?
By the way, checkout this story: https://yooocan.com/Story/329/Having-Wheels-Has-Its-Perks
Amazing people, and you're helping them James!
THANKS A LOT!
Copied from original issue: JimBobSquarePants/ImageProcessor#505
The text was updated successfully, but these errors were encountered: