Skip to content

Commit b76ef30

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix phpGH-10614: imagerotate will turn the picture all black, when rotated 90
2 parents 78986a6 + f26dd13 commit b76ef30

File tree

4 files changed

+98
-3
lines changed

4 files changed

+98
-3
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ PHP NEWS
2121
- GD:
2222
. Fixed bug GH-10344 (imagettfbbox(): Could not find/open font UNC path).
2323
(nielsdos)
24+
. Fixed bug GH-10614 (imagerotate will turn the picture all black, when
25+
rotated 90). (nielsdos)
2426

2527
- LibXML:
2628
. Fix crashes with entity references and predefined entities. (nielsdos)

ext/gd/libgd/gd_rotate.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ gdImagePtr gdImageRotate90 (gdImagePtr src, int ignoretransparent)
216216
if (dst != NULL) {
217217
int old_blendmode = dst->alphaBlendingFlag;
218218
dst->alphaBlendingFlag = 0;
219-
219+
dst->saveAlphaFlag = 1;
220220
dst->transparent = src->transparent;
221221

222222
gdImagePaletteCopy (dst, src);
@@ -263,7 +263,7 @@ gdImagePtr gdImageRotate180 (gdImagePtr src, int ignoretransparent)
263263
if (dst != NULL) {
264264
int old_blendmode = dst->alphaBlendingFlag;
265265
dst->alphaBlendingFlag = 0;
266-
266+
dst->saveAlphaFlag = 1;
267267
dst->transparent = src->transparent;
268268

269269
gdImagePaletteCopy (dst, src);
@@ -311,7 +311,7 @@ gdImagePtr gdImageRotate270 (gdImagePtr src, int ignoretransparent)
311311
if (dst != NULL) {
312312
int old_blendmode = dst->alphaBlendingFlag;
313313
dst->alphaBlendingFlag = 0;
314-
314+
dst->saveAlphaFlag = 1;
315315
dst->transparent = src->transparent;
316316

317317
gdImagePaletteCopy (dst, src);

ext/gd/tests/gh10614.phpt

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
--TEST--
2+
GH-10614 (imagerotate will turn the picture all black, when rotated 90)
3+
--EXTENSIONS--
4+
gd
5+
--SKIPIF--
6+
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.4', '>=')) die("skip test requires GD 2.3.4 or older");
8+
?>
9+
--FILE--
10+
<?php
11+
12+
$input = imagecreatefrompng(__DIR__ . '/gh10614.png');
13+
14+
for ($angle = 0; $angle <= 270; $angle += 90) {
15+
echo "--- Angle $angle ---\n";
16+
$output = imagerotate($input, $angle, 0);
17+
for ($i = 0; $i < 4; $i++) {
18+
for ($j = 0; $j < 4; $j++) {
19+
var_dump(dechex(imagecolorat($output, $i, $j)));
20+
}
21+
}
22+
}
23+
24+
?>
25+
--EXPECT--
26+
--- Angle 0 ---
27+
string(1) "0"
28+
string(1) "0"
29+
string(1) "0"
30+
string(1) "0"
31+
string(1) "0"
32+
string(1) "0"
33+
string(1) "0"
34+
string(1) "0"
35+
string(8) "7f000000"
36+
string(8) "7f000000"
37+
string(8) "7f000000"
38+
string(8) "7f000000"
39+
string(8) "7f000000"
40+
string(8) "7f000000"
41+
string(8) "7f000000"
42+
string(8) "7f000000"
43+
--- Angle 90 ---
44+
string(8) "7f000000"
45+
string(8) "7f000000"
46+
string(1) "0"
47+
string(1) "0"
48+
string(8) "7f000000"
49+
string(8) "7f000000"
50+
string(1) "0"
51+
string(1) "0"
52+
string(8) "7f000000"
53+
string(8) "7f000000"
54+
string(1) "0"
55+
string(1) "0"
56+
string(8) "7f000000"
57+
string(8) "7f000000"
58+
string(1) "0"
59+
string(1) "0"
60+
--- Angle 180 ---
61+
string(8) "7f000000"
62+
string(8) "7f000000"
63+
string(8) "7f000000"
64+
string(8) "7f000000"
65+
string(8) "7f000000"
66+
string(8) "7f000000"
67+
string(8) "7f000000"
68+
string(8) "7f000000"
69+
string(1) "0"
70+
string(1) "0"
71+
string(1) "0"
72+
string(1) "0"
73+
string(1) "0"
74+
string(1) "0"
75+
string(1) "0"
76+
string(1) "0"
77+
--- Angle 270 ---
78+
string(1) "0"
79+
string(1) "0"
80+
string(8) "7f000000"
81+
string(8) "7f000000"
82+
string(1) "0"
83+
string(1) "0"
84+
string(8) "7f000000"
85+
string(8) "7f000000"
86+
string(1) "0"
87+
string(1) "0"
88+
string(8) "7f000000"
89+
string(8) "7f000000"
90+
string(1) "0"
91+
string(1) "0"
92+
string(8) "7f000000"
93+
string(8) "7f000000"

ext/gd/tests/gh10614.png

98 Bytes
Loading

0 commit comments

Comments
 (0)