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

image/gif: decoding of some GIFs fails with error `gif: invalid pixel value` yet they open alright. #15059

odeke-em opened this issue Apr 1, 2016 · 3 comments


Copy link

@odeke-em odeke-em commented Apr 1, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version devel +ea306ae Fri Apr 1 04:13:44 2016 +0000 darwin/amd64
  2. What operating system and processor architecture are you using (go env)?
    GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -fno-common"
  3. What did you do?
    If possible, provide a recipe for reproducing the error.
    A complete runnable program is good
    A link on is best.
    Tried to decode a gif but it failed with error gif: invalid pixel value.
    Complete runnable program here
  4. What did you expect to see?
    Successful GIF decoding
  5. What did you see instead?
    error gif: invalid pixel value
@bradfitz bradfitz added this to the Go1.7 milestone Apr 7, 2016
Copy link

@nigeltao nigeltao commented Apr 28, 2016

It is indeed an invalid GIF image: the frame's palette only has 128 entries (i.e. valid values are from 0 to 127 inclusive), but the 'transparent index' is given as 128, which is outside the range [0, 127]. The GIF spec at says in section 22, Table Based Image Data, "Each index must be within the range of the size of the active color table".

Imagemagick similarly complains:

$ convert joker1.gif x.png
convert.im6: invalid colormap index `joker1.gif' @ error/colormap-private.h/ConstrainColormapIndex/34.

Nonetheless, it treats it as a warning, not an error. Furthemore, joker1.gif is viewable (with no visible error message) in both Firefox and Google Chrome, and by Eye-of-Gnome (which uses gdk-pixbuf). I suppose that it's a case of reality trumping the standard, and we should 'fix' this for Go.

Copy link

@gopherbot gopherbot commented Apr 28, 2016

CL mentions this issue.

Copy link
Member Author

@odeke-em odeke-em commented Apr 28, 2016

Thank you @nigeltao, this helps me quite a lot as I was encountering a lot of such gifs on the web and needed to import them

@gopherbot gopherbot closed this in 4618dd8 Apr 29, 2016
@golang golang locked and limited conversation to collaborators Apr 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.