From 2e34febb733742baf130a9dae4f30f48ffe74d48 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 13 Jul 2015 22:14:13 +0200 Subject: [PATCH 1/2] Fix #66882: imagerotate by -90 degrees truncates image by 1px Contrary to the external libgd, the bundled libgd doesn't use optimized rotation algorithms for negative square angles. We fix that now. There are other improvements in gdImageRotateInterpolated() in the external libgd. I'll leave them out for now, in the hope that we'll be able to rejoin the two libraries rather soon. --- ext/gd/libgd/gd_interpolation.c | 7 +++++-- ext/gd/tests/bug66882.phpt | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 ext/gd/tests/bug66882.phpt diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c index 32d69f9c205..5a3d7f4ee28 100644 --- a/ext/gd/libgd/gd_interpolation.c +++ b/ext/gd/libgd/gd_interpolation.c @@ -2178,10 +2178,13 @@ gdImagePtr gdImageRotateInterpolated(const gdImagePtr src, const float angle, in /* no interpolation needed here */ switch (angle_rounded) { - case 9000: + case -27000: + case 9000: return gdImageRotate90(src, 0); - case 18000: + case -18000: + case 18000: return gdImageRotate180(src, 0); + case -9000: case 27000: return gdImageRotate270(src, 0); } diff --git a/ext/gd/tests/bug66882.phpt b/ext/gd/tests/bug66882.phpt new file mode 100644 index 00000000000..6dfbdfe06de --- /dev/null +++ b/ext/gd/tests/bug66882.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #66882 (imagerotate by -90 degrees truncates image by 1px) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +int(10) +int(10) From 140e80acc03f3df886bcdefb6ebb7a92b2f41e05 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 13 Jul 2015 22:29:10 +0200 Subject: [PATCH 2/2] updated NEWS --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 776255307eb..85e89415e87 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ PHP NEWS . Fixed bug #64878 (304 responses return Content-Type header). (cmb) - GD: + . Fixed bug #66882 (imagerotate by -90 degrees truncates image by 1px). (cmb) . Fixed bug #70064 (imagescale(..., IMG_BICUBIC) leaks memory). (cmb) . Fixed bug #69024 (imagescale segfault with palette based image). (cmb) . Fixed bug #53154 (Zero-height rectangle has whiskers). (cmb)