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

Incorrect transparent GIF blending when it's transparent color is not black #116

Open
atomizer opened this issue Sep 4, 2011 · 3 comments

Comments

@atomizer
Copy link
Contributor

atomizer commented Sep 4, 2011

The value of the color marked as transparent is not discarded, but blended with background using "add" operation if the background isn't transparent.

For example, here is an image that is transparent, but the color of the transparent index in it's palette is set to #804000:
transparent gif

var assert = require('assert')
var Canvas = require('canvas')

var c = new Canvas(150, 150)
var ctx = c.getContext('2d')

// fill background with something non-transparent
ctx.fillStyle = 'rgb(0, 100, 200)'
ctx.fillRect(0, 0, 150, 150)
// load the (supposedly) transparent gif
var i = new Canvas.Image()
i.src = 'transparent.gif' // https://i.imgur.com/XCz0eVi.gif
// draw it on top of our background
ctx.drawImage(i, 0, 0)
// expect no visible change in the canvas
var pixel = ctx.getImageData(0, 0, 1, 1).data
assert.deepEqual(pixel, [0, 100, 200, 255])
@danschumann
Copy link

Is there still no fix for this? I noticed a dark border on my gif

@danschumann
Copy link

i take that back, it's working properly. the dark border is due to my pixel by pixel resize not properly handling it.

@atomizer atomizer changed the title transparent GIF blending Incorrect transparent GIF blending when it's transparent color is not black Jan 14, 2016
@atomizer
Copy link
Contributor Author

Updated test code and reuploaded the sample image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants