jnordberg / gif.js

JavaScript GIF encoding library
http://jnordberg.github.io/gif.js/
MIT License
4.74k stars 668 forks source link

My png image has a transparent "hole" but won't show up as transparent #123

Open HightonRidley opened 4 years ago

HightonRidley commented 4 years ago

I have a png image with a hole that's transparent. When I add it as a frame, the hole is no longer transparent. How can I make it so it's transparent? I've tried setting transparent: "rgba(0,0,0,0)" and also transparent: "#0x00000000" but neither work, eg: gif = new GIF({ workerScript: "js/gif-maker-lib/gif.worker.js", repeat: 0, workers: 2, width: 695, height: 695, transparent: "#0x00000000", quality: 10 });

cmann1 commented 4 years ago

"#0x00000000" doesn't really make sense. A CSS style hex string should be in a string in the form "#RRGGBB", eg. "#FF00FF" And a "JS" style colour value should be 0xRRGGBB (this is just another way to represent an integer, so no quotes), eg. 0xFF00FF

The "transparent" option expects an integer, so change that line to transparent: 0x00000000,