Skip to content

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

@jasdel

Description

@jasdel
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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions