Repository navigation
Move GD binary transparency handling from Cloner to GifEncoder - #1547
olivervogel wants to merge 16 commits into
Conversation
This reverts commit 24e301c.
|
Found it: it isn't the GD version but how libgd is built. setup-php installs PHP 8.3–8.5 from the ondrej PPA, whose $gd = imagecreatetruecolor(2, 1);
imagesetpixel($gd, 0, 0, 0x000000FF);
imagecolortransparent($gd, 0x000000FF);
// after imagegif(): transparent index 1 with Ubuntu's libgd, -1 with the PPA buildA fully transparent color (alpha 127) survives with both, which is why the current $mask = Cloner::clone($native); // copy incl. alpha
imagealphablending($mask, false); // the filters must not blend
imagefilter($mask, IMG_FILTER_BRIGHTNESS, 255); // rgb -> white, alpha kept
imagefilter($mask, IMG_FILTER_COLORIZE, 0, 0, 0, -126); // alpha 127 -> 1, others -> 0
imagefilter($mask, IMG_FILTER_COLORIZE, 0, 0, 0, 126); // -> 127 (transparent) or 126 (keep)
imagecolortransparent($mask, 0x7EFFFFFF); // imagecopy() skips the pixels to keep
imagealphablending($gd, false);
imagecopy($gd, $mask, 0, 0, 0, 0, imagesx($gd), imagesy($gd));
imagecolortransparent($gd, 0x7FFFFFFF);I tested this with Ubuntu's libgd, the PPA build and PHP's bundled GD. Fully transparent pixels and sources with a transparent color (e.g. |
|
Thanks. This helps. |
No description provided.