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: Decode(All) replacing transparent background of frame with black #7993

Closed
jasdel opened this issue May 14, 2014 · 10 comments
Closed

image/gif: Decode(All) replacing transparent background of frame with black #7993

jasdel opened this issue May 14, 2014 · 10 comments
Milestone

Comments

@jasdel
Copy link
Contributor

@jasdel jasdel commented May 14, 2014

Optimized GIFs that use a color palette combined with transparency over a colored
background when decoded will have the background color ignored. causing the formerly
transparent pixels to be black once decoded.

What does 'go version' print?
Verified against 1.2.1, 1.2.2, 1.3beta1

What steps reproduce the problem?
Decoding optimized gif with transparency over colored background. 

If possible, include a link to a program on play.golang.org.
Original Image: http://i.imgur.com/nGsYOhn.gif

1. gif.DecodeAll, then gif.EncodeAll out new file.  The frames will have black pixels
replaced where transparency should of been.
- http://play.golang.org/p/z8VwdM7jfS
- Resulting image: http://i.imgur.com/59gSWgw.gif

2. gif.Decode, then jpeg.Encode out new file. The single frame that is encoded will have
black pixels where the transparency should of been.
- http://play.golang.org/p/WPvkNmpiw4
- Resulting image: http://i.imgur.com/ZSxA5nO.jpeg

What happened?
Transparency replaced with black pixels

What should have happened instead?
transparency over colored background should be maintained.

Please provide any additional information below.

Attachments:

  1. original.gif (1298657 bytes)
  2. AfterDecodeAll-EncodeAll.gif (1316042 bytes)
  3. AftergifDecode-jpegEncode.jpeg (14923 bytes)
@jasdel
Copy link
Contributor Author

@jasdel jasdel commented May 14, 2014

Comment 1:

Look like gifs have to be downloaded from the issue board before they animate.
@nigeltao
Copy link
Contributor

@nigeltao nigeltao commented May 15, 2014

Comment 2:

Owner changed to @nigeltao.

Status changed to Accepted.

@rui314
Copy link
Member

@rui314 rui314 commented May 15, 2014

Comment 3:

Is this image corrupt? ImageMagick's display command also displays broken images when I
gave the original file to it. The command even crashed when I tried to display the fifth
frame with "display 'nGsYOhn.gif[5]'".
@jasdel
Copy link
Contributor Author

@jasdel jasdel commented May 15, 2014

Comment 4:

Not to say nGsYOhn.gif isn't corrupt but I see similar black pixelization occurs with
http://thechive.files.wordpress.com/2014/05/tumblr_n2gyjqaxz81s8ve6co1_500.gif.
Also since you mentioned image corruption, ubuntu's default Image Viewer(3.10.2)
actually refuses to display, and ubuntu(14.04) showing thumbnails, for any of the gifs
after they have been read then written by image/gif. I don't know if this is directly
related to the black instead of transparent coloring, or not. Both Firefox and chrome
will display this image/gif written images.

Attachments:

  1. tumblr_n2gyjqaxz81s8ve6co1_500.gif (976200 bytes)
@rsc
Copy link
Contributor

@rsc rsc commented May 21, 2014

Comment 5:

Labels changed: added release-go1.4.

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 12, 2014

Comment 6 by james.jdunne:

I forked the standard image/gif package and fixed these bugs myself but unfortunately it
required breaking the GIF struct contract (changing *image.Paletted to *image.RGBA).
This means that the writer.go code no longer compiles, so in my fork I just removed it
since I didn't need it. Perhaps this change wasn't strictly necessary but it did resolve
a few bugs I was banging my head against the wall with.
Please see my work here: https://github.com/JamesDunne/go-util/tree/master/imaging/gif
If anything, it could serve as a baseline for correcting the standard image/gif
implementation. I have tested it extensively on my own library of animated GIFs so I
know it's good.
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 17, 2014

Comment 7 by james.jdunne:

I've reverted my changes in my repository back to using `image.Paletted` instead of
`image.RGBA`. Decoding and encoding should work now, with minor changes to the `GIF`
struct contract.
@rsc
Copy link
Contributor

@rsc rsc commented Sep 15, 2014

Comment 8:

Nigel, will you get to this for 1.4? If not postpone to 1.5 please.
@gopherbot
Copy link

@gopherbot gopherbot commented Sep 18, 2014

Comment 9:

CL https://golang.org/cl/138600043 mentions this issue.
@nigeltao
Copy link
Contributor

@nigeltao nigeltao commented Sep 22, 2014

Comment 10:

This issue was closed by revision 0be3176.

Status changed to Fixed.

@jasdel jasdel added fixed labels Sep 22, 2014
@rsc rsc added this to the Go1.4 milestone Apr 14, 2015
@rsc rsc removed the release-go1.4 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman added a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
wheatman added a commit to wheatman/go-akaros that referenced this issue Jul 9, 2018
wheatman added a commit to wheatman/go-akaros that referenced this issue Jul 30, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.