-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
image/gif: "not enough image data" on gif that works in browser #38958
Comments
While my browser does indeed display it, that image is definitely corrupted and/or badly formed; imagemagick says:
and my system's image viewer also refuses to open it. This is similar to #9856, when cc @nigeltao |
To read this image, there need to be two changes to the gif decoder. I have made these changes in a modified (1) Allow the lzw reader to encounter short reads in the stream. Line 427 in 4f65fb3
(2) Handle zero-bytes sandwiched inside parts of the image. Lines 243 to 258 in 4f65fb3
After this, the author's test program correctly decodes the image.
|
Coincidentally, |
@nigeltao That patch is necessary to fix it, but alone isn't sufficient. The LZW reader case (1) also needs to be handled. |
The above image is even-more problematic. It contains a byte interpreted as an invalid LZW code (0x66) instead of (0x00) like the first image. To fix that, I had to elide almost all error checks and then ignore the 0x66 byte. Perhaps other decoders silently ignore garbage input entirely and march forward hoping to eventually draw a valid-looking image. Which encoder produced these? The image contains this metadata (which may give us a clue above the question above):
|
There are images which browsers can render but which image/gif chokes on.
The following runs successfully for most gifs:
But when trying to run it on a particular gif (below), this happens:
$ go run main.go
Here’s the offending gif
The text was updated successfully, but these errors were encountered: