From 0da7022eb6ed7c0939756d670b958173265b70d9 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Thu, 25 Jan 2024 23:30:23 +0100 Subject: [PATCH] Fix GH-10614: imagerotate will turn the picture all black, when rotated 90 This is a backport of the upstream libgd PR that was recently committed [1]. [1] https://github.com/libgd/libgd/pull/862 --- ext/gd/libgd/gd_rotate.c | 6 +-- ext/gd/tests/gh10614.phpt | 93 ++++++++++++++++++++++++++++++++++++++ ext/gd/tests/gh10614.png | Bin 0 -> 98 bytes 3 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 ext/gd/tests/gh10614.phpt create mode 100644 ext/gd/tests/gh10614.png diff --git a/ext/gd/libgd/gd_rotate.c b/ext/gd/libgd/gd_rotate.c index cc89652f03f79..53c6c9470db79 100644 --- a/ext/gd/libgd/gd_rotate.c +++ b/ext/gd/libgd/gd_rotate.c @@ -216,7 +216,7 @@ gdImagePtr gdImageRotate90 (gdImagePtr src, int ignoretransparent) if (dst != NULL) { int old_blendmode = dst->alphaBlendingFlag; dst->alphaBlendingFlag = 0; - + dst->saveAlphaFlag = 1; dst->transparent = src->transparent; gdImagePaletteCopy (dst, src); @@ -263,7 +263,7 @@ gdImagePtr gdImageRotate180 (gdImagePtr src, int ignoretransparent) if (dst != NULL) { int old_blendmode = dst->alphaBlendingFlag; dst->alphaBlendingFlag = 0; - + dst->saveAlphaFlag = 1; dst->transparent = src->transparent; gdImagePaletteCopy (dst, src); @@ -311,7 +311,7 @@ gdImagePtr gdImageRotate270 (gdImagePtr src, int ignoretransparent) if (dst != NULL) { int old_blendmode = dst->alphaBlendingFlag; dst->alphaBlendingFlag = 0; - + dst->saveAlphaFlag = 1; dst->transparent = src->transparent; gdImagePaletteCopy (dst, src); diff --git a/ext/gd/tests/gh10614.phpt b/ext/gd/tests/gh10614.phpt new file mode 100644 index 0000000000000..c0689141837cd --- /dev/null +++ b/ext/gd/tests/gh10614.phpt @@ -0,0 +1,93 @@ +--TEST-- +GH-10614 (imagerotate will turn the picture all black, when rotated 90) +--EXTENSIONS-- +gd +--SKIPIF-- +=')) die("skip test requires GD 2.3.4 or older"); +?> +--FILE-- + +--EXPECT-- +--- Angle 0 --- +string(1) "0" +string(1) "0" +string(1) "0" +string(1) "0" +string(1) "0" +string(1) "0" +string(1) "0" +string(1) "0" +string(8) "7f000000" +string(8) "7f000000" +string(8) "7f000000" +string(8) "7f000000" +string(8) "7f000000" +string(8) "7f000000" +string(8) "7f000000" +string(8) "7f000000" +--- Angle 90 --- +string(8) "7f000000" +string(8) "7f000000" +string(1) "0" +string(1) "0" +string(8) "7f000000" +string(8) "7f000000" +string(1) "0" +string(1) "0" +string(8) "7f000000" +string(8) "7f000000" +string(1) "0" +string(1) "0" +string(8) "7f000000" +string(8) "7f000000" +string(1) "0" +string(1) "0" +--- Angle 180 --- +string(8) "7f000000" +string(8) "7f000000" +string(8) "7f000000" +string(8) "7f000000" +string(8) "7f000000" +string(8) "7f000000" +string(8) "7f000000" +string(8) "7f000000" +string(1) "0" +string(1) "0" +string(1) "0" +string(1) "0" +string(1) "0" +string(1) "0" +string(1) "0" +string(1) "0" +--- Angle 270 --- +string(1) "0" +string(1) "0" +string(8) "7f000000" +string(8) "7f000000" +string(1) "0" +string(1) "0" +string(8) "7f000000" +string(8) "7f000000" +string(1) "0" +string(1) "0" +string(8) "7f000000" +string(8) "7f000000" +string(1) "0" +string(1) "0" +string(8) "7f000000" +string(8) "7f000000" diff --git a/ext/gd/tests/gh10614.png b/ext/gd/tests/gh10614.png new file mode 100644 index 0000000000000000000000000000000000000000..baf1ea92fc9ce3dcf9c432876ec32f4de97d8dc4 GIT binary patch literal 98 zcmeAS@N?(olHy`uVBq!ia0vp^EFjFm1|(O0oL2|p6gzo_Z~#FKM@k2fFX`#x7{W0# oIUyn82metX5b)v2XxPBOP&0*z_4C4BZ=fOuPgg&ebxsLQ0Hm}QTmS$7 literal 0 HcmV?d00001