From d95b8eaf31eb0613754b7aa38388cf038ed994fc Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sat, 24 Sep 2016 14:44:57 +0200 Subject: [PATCH] Don't enforce palette conversion when writing GD images The GD image format is able to handle truecolor images as of libgd 2.0.12 (). Therefore we don't need the potentially lossy and time consuming palette conversion. This way, imagegd() can also be used to export raw truecolor image data. --- UPGRADING | 2 ++ ext/gd/gd.c | 6 ----- ext/gd/tests/imagegd_truecolor.phpt | 34 ++++++++++++++++++++++++++++ ext/gd/tests/imagegd_truecolor.png | Bin 0 -> 117 bytes 4 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 ext/gd/tests/imagegd_truecolor.phpt create mode 100644 ext/gd/tests/imagegd_truecolor.png diff --git a/UPGRADING b/UPGRADING index feef5d61c8..2c66c4263a 100644 --- a/UPGRADING +++ b/UPGRADING @@ -95,6 +95,8 @@ PHP 7.2 UPGRADE NOTES - GD: . Removed --enable-gd-native-ttf configuration option which was unused as of PHP 5.5.0 anyway. + . imagegd() stores truecolor images as real truecolor images. Formerly, they + have been converted to palette. - Mbstring . mb_check_encoding() accepts array parameter. Both key and value diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 29e5175286..739c069dd1 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -2565,9 +2565,6 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char (*func_p)(im, i, fp); break; case PHP_GDIMG_TYPE_GD: - if (im->trueColor){ - gdImageTrueColorToPalette(im,1,256); - } (*func_p)(im, fp); break; case PHP_GDIMG_TYPE_GD2: @@ -2619,9 +2616,6 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char (*func_p)(im, q, tmp); break; case PHP_GDIMG_TYPE_GD: - if (im->trueColor) { - gdImageTrueColorToPalette(im,1,256); - } (*func_p)(im, tmp); break; case PHP_GDIMG_TYPE_GD2: diff --git a/ext/gd/tests/imagegd_truecolor.phpt b/ext/gd/tests/imagegd_truecolor.phpt new file mode 100644 index 0000000000..1eedae484f --- /dev/null +++ b/ext/gd/tests/imagegd_truecolor.phpt @@ -0,0 +1,34 @@ +--TEST-- +imagegd() writes truecolor images without palette conversion +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +signature: 65534 +truecolor: 1 +size: 411 +The images are equal. +===DONE=== diff --git a/ext/gd/tests/imagegd_truecolor.png b/ext/gd/tests/imagegd_truecolor.png new file mode 100644 index 0000000000000000000000000000000000000000..8c77c9f4224eebe12c045ae452e8274626e8e62e GIT binary patch literal 117 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V6Od#Ih^ zi(`ny)Z{<^|JyU?9cXdy+hD>y=je$Jf!1h`nGaoV_g-zDBFV>a@d3N=^*5KofLa(l MUHx3vIVCg!05L5hfB*mh literal 0 HcmV?d00001 -- 2.50.1