From bb064b29fd3d49a2f4b0e122a3d6d766d6eb176d Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 17 Jan 2024 20:54:58 +0000 Subject: [PATCH] Fix FG-13163 attempt imagecrop on transparent background. based on @nielsdos proposal. patches on the embedded version of libgd. Fixing mismatch color model between imageallocatealpha using gdImageGetTransparent and gdImageCropAuto usage. thankfully CI does not use external gd flag. --- ext/gd/libgd/gd_crop.c | 2 +- ext/gd/tests/gh13163.phpt | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 ext/gd/tests/gh13163.phpt diff --git a/ext/gd/libgd/gd_crop.c b/ext/gd/libgd/gd_crop.c index 676545c4dbc92..2791dac10e37e 100644 --- a/ext/gd/libgd/gd_crop.c +++ b/ext/gd/libgd/gd_crop.c @@ -92,7 +92,7 @@ gdImagePtr gdImageCropAuto(gdImagePtr im, const unsigned int mode) switch (mode) { case GD_CROP_TRANSPARENT: - color = gdImageGetTransparent(im); + color = gdImageGetTransparent(im) & 0x7f000000; break; case GD_CROP_BLACK: diff --git a/ext/gd/tests/gh13163.phpt b/ext/gd/tests/gh13163.phpt new file mode 100644 index 0000000000000..7daf59c62c5b3 --- /dev/null +++ b/ext/gd/tests/gh13163.phpt @@ -0,0 +1,13 @@ +--TEST-- +GH-13163 (imagecrop on transparent background) +--EXTENSIONS-- +gd +--FILE-- +