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: encoded images incompatible with some viewers #26108

Closed
powerman opened this issue Jun 28, 2018 · 6 comments
Closed

image/gif: encoded images incompatible with some viewers #26108

powerman opened this issue Jun 28, 2018 · 6 comments
Labels
FrozenDueToAge help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@powerman
Copy link

What version of Go are you using (go version)?

go version go1.10.3 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/powerman/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/powerman/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="x86_64-pc-linux-gnu-gcc"
CXX="x86_64-pc-linux-gnu-g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build380688713=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Just gif.Decode and then gif.Encode: https://play.golang.org/p/AMc63K13IHZ

What did you expect to see?

Encoded image must be valid.

What did you see instead?

Some image viewers and browsers show encoded image correctly, some (gqview, geeqie, qiv, xloadimage…) show broken image.

More details with attached image examples are here: BestImageViewer/geeqie#621

@minaevmike
Copy link
Contributor

minaevmike commented Jun 28, 2018

Hi @powerman . I think that your problem is similar to this one. Imagemagick tools works fine with this image. Am i right, that all of this viewers is based on gtk library?
Also there is an open bug for gdk-pixbuf https://gitlab.gnome.org/GNOME/gdk-pixbuf/issues/55

@powerman
Copy link
Author

powerman commented Jun 28, 2018

Thanks @minaevmike, you probably right, it's the same issue. I didn't tried every viewer, but from two tried by geeqie author one doesn't use GTK:

$ xloadimage out.gif                                                                           
out.gif is a 96x96 GIF image with 256 colors
Error reading GIF file: pixel stack overflow in PUSH_PIXEL()
$ ldd =xloadimage                                                                              
	linux-vdso.so.1 (0x000076c96ea14000)
	libX11.so.6 => /usr/lib64/libX11.so.6 (0x000076c96dfe5000)
	libtiff.so.5 => /usr/lib64/libtiff.so.5 (0x000076c96dd69000)
	libjpeg.so.62 => /usr/lib64/libjpeg.so.62 (0x000076c96dafd000)
	libpng16.so.16 => /usr/lib64/libpng16.so.16 (0x000076c96d8c2000)
	libm.so.6 => /lib64/libm.so.6 (0x000076c96d57a000)
	libc.so.6 => /lib64/libc.so.6 (0x000076c96d1b5000)
	libdl.so.2 => /lib64/libdl.so.2 (0x000076c96cfb1000)
	libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x000076c96cd82000)
	libz.so.1 => /lib64/libz.so.1 (0x000076c96cb6a000)
	/lib64/ld-linux-x86-64.so.2 (0x000076c96e7f2000)
	libXau.so.6 => /usr/lib64/libXau.so.6 (0x000076c96c966000)
	libXdmcp.so.6 => /usr/lib64/libXdmcp.so.6 (0x000076c96c760000)
	libbsd.so.0 => /usr/lib64/libbsd.so.0 (0x000076c96c54a000)
	librt.so.1 => /lib64/librt.so.1 (0x000076c96c342000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x000076c96c122000)

So, while it looks like there is a bug in gdk-pixbuf, and probably a bug in some basic library used by xloadimage, still, it doesn't looks like a good idea to have image/gif generate files which can't be read by noticeable amount of existing viewers (all based on GTK plust all based on same basic lib as used by xloadimage, at least - to me this sounds "noticeable amount"). I'm pretty sure it is possible to generate gif files in some other way, more usual for all these viewers, because all(?) other non-Go tools which create gif files doesn't have this issue.

@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 28, 2018
@bcmills bcmills added this to the Go1.12 milestone Jun 28, 2018
@bcmills bcmills changed the title image/gif: Encode output invalid images image/gif: encoded images incompatible with some viewers Jun 28, 2018
@bcmills
Copy link
Contributor

bcmills commented Jun 28, 2018

(CC: @robpike for image/, @nigeltao for image/gif)

@robpike
Copy link
Contributor

robpike commented Jun 29, 2018

No idea. With no information about the actual issue, it's hard to do anything useful.

@makew0rld
Copy link

I believe this is the same issue as #33748. See this comment and ones below it that explain why this is happening.

@gopherbot
Copy link

Change https://golang.org/cl/354710 mentions this issue: compress/lzw: output a Clear code first, per GIF spec

@golang golang locked and limited conversation to collaborators Oct 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

7 participants