image/gif color corruption with DecodeAll/EncodeAll

198 views
Skip to first unread message

Jason Del Ponte

unread,
May 14, 2014, 10:35:14 AM5/14/14
to golan...@googlegroups.com
I'm seeing an odd issue with image/gif.  When an image is loaded with gif.DecodeAll, and written to a new file, with no manipulations, via gif.EncodeAll sections of each frame are black when they shouldn't be.

Not sure if i'm missing something when using image/gif, or if this is a bug in the package.  It looks like the compressed fill parts of the original image are lost, and replaced with black pixels(Default background color?) when written again. I'm not sure how to identify if this problem is happening on the encoding or decoding side.


(Running on Ubuntu 14.04 x86_64)

Also looks like the same issue is occurring with just gif.Encode and gif.Decode when writing just the first frame. http://i.imgur.com/IHwEXuY.gif

Cheers,
Jason

Jason Del Ponte

unread,
May 14, 2014, 10:37:01 AM5/14/14
to golan...@googlegroups.com
Forgot to mention I've reproduced this on 1.2.1, 1.2.2, and 1.3beta1 the same way.

Andy Bonventre

unread,
May 14, 2014, 10:45:55 AM5/14/14
to Jason Del Ponte, golan...@googlegroups.com
If you decode and then encode to another image format like jpeg, does the issue still present itself? That would help you narrow down at what step the issue is happening.


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James Bardin

unread,
May 14, 2014, 10:54:17 AM5/14/14
to golan...@googlegroups.com

Your gif is optimized in such a way that it uses a color palette combined with transparency over a colored background.

I don't think the Go gif coders don't really handle background color.
It looks like background color is ignored during decoding, and written ad 0x00 (black) during encoding.

Andy Bonventre

unread,
May 14, 2014, 10:57:25 AM5/14/14
to James Bardin, golan...@googlegroups.com
This is what I see when encoding the first frame to a jpeg after decoding from your original gif:

Inline image 1

James is correct. Please file an issue for the decoder.


--

Jason Del Ponte

unread,
May 14, 2014, 10:58:50 AM5/14/14
to golan...@googlegroups.com
I think you're right. encoding to jpeg maintains the same loose. http://i.imgur.com/ZSxA5nO.jpeg

Thanks! I'll open an issue.

Jason Del Ponte

unread,
May 14, 2014, 1:25:46 PM5/14/14
to golan...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages