From 26970a206c5cbd69e1351cbac453af5acb47f28b Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sat, 4 Jan 2025 00:11:56 +0100 Subject: [PATCH] Fix GH-17349: Tiled truecolor filling looses single color transparency This is porting the relevant part of a previous upstream commit[1] to align the behavior of our bundled libgd with upstream. It should be noted that this only works if the image actually has a transparent color. [1] --- ext/gd/libgd/gd.c | 4 +++- ext/gd/tests/gh17349.phpt | 27 +++++++++++++++++++++++++++ ext/gd/tests/gh17349.png | Bin 0 -> 417 bytes 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 ext/gd/tests/gh17349.phpt create mode 100644 ext/gd/tests/gh17349.png diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 2664288162a7..7265758696ad 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -960,7 +960,9 @@ static int gdImageTileGet (gdImagePtr im, int x, int y) srcy = y % gdImageSY(im->tile); p = gdImageGetPixel(im->tile, srcx, srcy); - if (im->trueColor) { + if (p == im->tile->transparent) { + tileColor = im->transparent; + } else if (im->trueColor) { if (im->tile->trueColor) { tileColor = p; } else { diff --git a/ext/gd/tests/gh17349.phpt b/ext/gd/tests/gh17349.phpt new file mode 100644 index 000000000000..cd0fc4317b59 --- /dev/null +++ b/ext/gd/tests/gh17349.phpt @@ -0,0 +1,27 @@ +--TEST-- +GH-17349 (Tiled truecolor filling looses single color transparency) +--EXTENSIONS-- +gd +--FILE-- + +--EXPECT-- +The images are equal. diff --git a/ext/gd/tests/gh17349.png b/ext/gd/tests/gh17349.png new file mode 100644 index 0000000000000000000000000000000000000000..dd75d9df990434a3ec85f54cbcd0155ea77e6df5 GIT binary patch literal 417 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1SD0tpLGH$wvr&fV21x7XdWS53l!lj@Q5sC zVBk9f!i-b3`J@>b7#%%b978f1-_CLrJFLLrvT^I*kdm}kabwwigeb{}jh*OmH zx2qWMmTl5=!%RO;jk=gUb*kir+={8cn!X>n`-*YFcR!m}{fANp0sS7f8+c}{ba#<^ z#@2IHxrYDYb0=YDy|euW&I@=fR=HcqeJWG@{>*)uqKfZ>3D4YL2uxBF=;&eVlVad7 z~T7tN*NWY?>>+YehzN((4_)8JhevxMlso7Jp`xce)+OH)oPLFoYRAUHx3v IIVCg!08N{xlmGw# literal 0 HcmV?d00001