Skip to content

Commit 4c68fc5

Browse files
committed
Merge branch 'PHP-5.6' into PHP-7.0
2 parents 7a36056 + d65adac commit 4c68fc5

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ PHP NEWS
1818
. Fixed bug #72709 (imagesetstyle() causes OOB read for empty $styles). (cmb)
1919
. Fixed bug #66005 (imagecopy does not support 1bit transparency on truecolor
2020
images). (cmb)
21+
. Fixed bug #72913 (imagecopy() loses single-color transparency on palette
22+
images). (cmb)
2123

2224
- IMAP:
2325
. Fixed bug #72852 (imap_mail null dereference). (Anatol)

ext/gd/libgd/gd.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,26 +2264,6 @@ void gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX,
22642264
return;
22652265
}
22662266

2267-
/* Destination is palette based */
2268-
if (src->trueColor) { /* But source is truecolor (Ouch!) */
2269-
toy = dstY;
2270-
for (y = srcY; (y < (srcY + h)); y++) {
2271-
tox = dstX;
2272-
for (x = srcX; x < (srcX + w); x++) {
2273-
int nc;
2274-
c = gdImageGetPixel (src, x, y);
2275-
2276-
/* Get best match possible. */
2277-
nc = gdImageColorResolveAlpha(dst, gdTrueColorGetRed(c), gdTrueColorGetGreen(c), gdTrueColorGetBlue(c), gdTrueColorGetAlpha(c));
2278-
2279-
gdImageSetPixel(dst, tox, toy, nc);
2280-
tox++;
2281-
}
2282-
toy++;
2283-
}
2284-
return;
2285-
}
2286-
22872267
/* Palette based to palette based */
22882268
for (i = 0; i < gdMaxColors; i++) {
22892269
colorMap[i] = (-1);

ext/gd/tests/bug72913.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Bug #72913 (imagecopy() loses single-color transparency on palette images)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('gd')) die('skip gd extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$base64 = 'iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAABnRSTlMAAAAAAABu'
10+
. 'pgeRAAAAVklEQVRYw+3UQQqAMBAEwf3/p9eTBxEPiWAmWMU8oGFJqgAAuOpzWTX3'
11+
. 'xQUti+uRJTZ9V5aY1bOTFZLV7yZr9zt6ibv/qPXfrMpsGipbIy7oqQ8AYJED1plD'
12+
. 'y5PCu2sAAAAASUVORK5CYII=';
13+
$src = imagecreatefromstring(base64_decode($base64));
14+
15+
$dst = imagecreate(50, 50);
16+
$transparent = imagecolorallocatealpha($dst, 255, 255, 255, 127);
17+
imagealphablending($dst, false);
18+
imagesavealpha($dst, true);
19+
20+
imagecopy($dst, $src, 0,0, 0,0, 50,50);
21+
22+
ob_start();
23+
imagegd($dst);
24+
echo md5(ob_get_clean()), PHP_EOL;
25+
?>
26+
==DONE==
27+
--EXPECT--
28+
f03c27f20710e21debd7090c660f1a1e
29+
==DONE==

0 commit comments

Comments
 (0)