Skip to content

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

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

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

Comments

@odeke-em
Copy link
Member

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)?
    GOARCH="amd64"
    GOBIN="/Users/emmanuelodeke/go/bin"
    GOEXE=""
    GOHOSTARCH="amd64"
    GOHOSTOS="darwin"
    GOOS="darwin"
    GOPATH="/Users/emmanuelodeke/go"
    GORACE=""
    GOROOT="/Users/emmanuelodeke/go/src/go.googlesource.com/go"
    GOTOOLDIR="/Users/emmanuelodeke/go/src/go.googlesource.com/go/pkg/tool/darwin_amd64"
    CC="clang"
    GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -fno-common"
    CXX="clang++"
    CGO_ENABLED="1"
  3. What did you do?
    If possible, provide a recipe for reproducing the error.
    A complete runnable program is good http://play.golang.org/p/_8PzZ6RffI.
    A link on play.golang.org is best.
    Tried to decode a gif https://brobible.files.wordpress.com/2016/03/joker1.gif but it failed with error gif: invalid pixel value.
    Complete runnable program here http://play.golang.org/p/_8PzZ6RffI
  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
@nigeltao
Copy link
Contributor

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 https://www.w3.org/Graphics/GIF/spec-gif89a.txt 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.

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/22546 mentions this issue.

@odeke-em
Copy link
Member Author

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

@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.
Projects
None yet
Development

No branches or pull requests

4 participants