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: result of EncodeAll not viewable in Eye of GNOME #13746
Comments
I have a similar issue with this code: package main
import (
"bytes"
"image"
"image/color"
"image/gif"
"io/ioutil"
)
func main() {
g := &gif.GIF{
Image: []*image.Paletted{
image.NewPaletted(image.Rect(0, 0, 100, 100), color.Palette{color.RGBA{0xff, 0, 0, 0xff}}),
},
Delay: []int{
0,
},
}
buf := new(bytes.Buffer)
err := gif.EncodeAll(buf, g)
if err != nil {
panic(err)
}
err = ioutil.WriteFile("test.gif", buf.Bytes(), 0644)
if err != nil {
panic(err)
}
} Eye of GNOME says: "GIF image loader cannot understand this image." |
/cc @nigeltao |
Animated GIF aficionados will have to wait for Go 1.7. |
Sorry for the late reply. I've been away for some months now, for non-work-related reasons. I'll look at this for Go 1.7. |
go version: Gahh! So one of the first examples in The Go Programming Language book is the lissajous example (https://github.com/adonovan/gopl.io/blob/master/ch1/lissajous/main.go) and while it outputs a file it appears to be non-valid. This would potentially explain why. |
@pierrre, I believe that these are bugs with Eye-of-Gnome (i.e with gdk-pixbuf) instead of with Go. In particular, I think that gdk-pixbuf's LZW decompressor is at fault. For example, the "GIF image loader cannot understand this image" error message comes from https://github.com/GNOME/gdk-pixbuf/blob/master/gdk-pixbuf/io-gif.c#L634 in the lzw_read_byte function, and the comment immediately above that says: "FIXME - we should handle this case". I filed a bug on the gdk-pixbuf project: https://bugzilla.gnome.org/show_bug.cgi?id=765705 @tanepiper, I need more information than "it appears to be non-valid". What programs did you try and open that output file with? What error messages (if any) did it show? Did you try various browsers: Firefox, Google Chrome, Internet Explorer? |
Thank you ! |
@nigeltao The above example is in the first chapter of http://www.gopl.io/ The book example actually starts off without the web server, here is my version of it: https://gist.github.com/tanepiper/658606e9c424f876f284f60eeaea16cc I've attached the output gif, the output it compiled with You are correct in that the web version does seem to work (sorry I passed this example in the book after spending a frutsrating hour trying to get the first version working) but when outputting to a file (e.g. Anyway appreciate the response and that it's not a issue with the gif library. |
Hah! So on a random whim tried it in cmd.exe rather than Powershell and it worked! So it seems it's something screwy with Powershell and Stdout. How annoying 😠 |
Perhaps Powershell is converting "\n" to "\r\n", but that's only a guess, and I don't know how to stop that. I'm not much of a Windows dev. In your Go program, I suspect that you can work around it by writing to a file (the result of os.Create) instead of to os.Stdout. |
For anyone specifically concerned about the EoG (Eye of GNOME) image viewer, they re-wrote their GIF decoder in December 2018: GNOME/gdk-pixbuf@b88f1ce I don't know whether that fixes the OP's bug report. |
Go version: 1.5.2 & 1.6beta1 linux/amd64
Architecture:
Linux pierre-vm 4.2.5-1-ARCH #1 SMP PREEMPT Tue Oct 27 08:13:28 CET 2015 x86_64 GNU/Linux
With this image: https://raw.githubusercontent.com/pierrre/imageserver/master/testdata/animated.gif
Run:
If I open the encoded image (
test.gif
) with Eye of GNOME 3.18.1 (default image viewer on Gnome), I get an error message: "Circular table entry in GIF file".I can open the original image with Eye of GNOME.
I can open the encoded image with Firefox, Chrome, or XnView.
The text was updated successfully, but these errors were encountered: