Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
image/gif: GIF encoder corrupts subimages #7792
What does 'go version' print? go version devel +8e5787506b59 Tue Apr 15 15:52:23 2014 -0400 + linux/amd64 What steps reproduce the problem? If possible, include a link to a program on play.golang.org. 1. Create an image in a GIF where the bounds of the Paletted image is different from the backing pixel slice. For example, create an image using Paletted.SubImage() that is narrower than the original image. 2. Attempt to encode this GIF. Example (needs file access): http://play.golang.org/p/Ck6A7ih6Hv What happened? The frame created from the subimage looks corrupted (example in buggy.gif) What should have happened instead? The frame should look correct (example in fixed.gif) Please provide any additional information below. Looks like this is due to the "common mistake" described at http://blog.golang.org/go-image-package#TOC_4. where it is assumed that the backing data matches the dimensions of the image. The encoder attempts to write the entire Px slice instead of respecting the image bounds: http://golang.org/src/pkg/image/gif/writer.go?s=5197:5226#L236 The attached patch appears to fix it. I'd be happy to make a CL once I figure out the review tools.
Note that the examples are animated GIFs (the issue tracker only shows the first frame unless you download them). This can affect single frame GIFs as well, but I wanted to make the examples clearly distinct from issue #6635 (image/gif: encoder does not honor image bounds).