com php-src: Fix #73272: imagescale() affects imagesetinterpolation(): NEWS ext/gd/gd.c ext/gd/tests/bug73272.phpt ext/gd/tests/bug73272.png

From: Date: Sun, 09 Oct 2016 13:10:34 +0000
Subject: com php-src: Fix #73272: imagescale() affects imagesetinterpolation(): NEWS ext/gd/gd.c ext/gd/tests/bug73272.phpt ext/gd/tests/bug73272.png
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-94877@lists.php.net to get a copy of this message
Commit: b92216b97dcdae738ae24d9bdd1168565dc04406 Author: Christoph M. Becker <cmbecker69@gmx.de> Sun, 9 Oct 2016 14:59:37 +0200 Parents: 3c5742ebd735d03468048edbca434769dffec8f4 Branches: PHP-5.6 PHP-7.0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b92216b97dcdae738ae24d9bdd1168565dc04406 Log: Fix #73272: imagescale() affects imagesetinterpolation() We must not permanently change the interpolation method, but rather have to restore the old method after we're done with scaling the image. Bugs: https://bugs.php..net/73272 Changed paths: M NEWS M ext/gd/gd.c A ext/gd/tests/bug73272.phpt A ext/gd/tests/bug73272.png Diff: diff --git a/NEWS b/NEWS index e9e4b94..a41168d 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ PHP NEWS -GD: . Fixed bug #73213 (Integer overflow in imageline() with antialiasing). (cmb) + . Fixed bug #73272 (imagescale() is not affected by, but affects + imagesetinterpolation()). (cmb) - Standard: . Fixed bug #73203 (passing additional_parameters causes mail to fail). (cmb) diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 5f08686..39cb4eb 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -5175,7 +5175,7 @@ PHP_FUNCTION(imagescale) gdImagePtr im_scaled = NULL; int new_width, new_height; long tmp_w, tmp_h=-1, tmp_m = GD_BILINEAR_FIXED; - gdInterpolationMethod method; + gdInterpolationMethod method, old_method; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|ll", &IM, &tmp_w, &tmp_h, &tmp_m) == FAILURE) { return; @@ -5202,9 +5202,12 @@ PHP_FUNCTION(imagescale) new_width = tmp_w; new_height = tmp_h; + /* gdImageGetInterpolationMethod() is only available as of GD 2.1.1 */ + old_method = im->interpolation_id; if (gdImageSetInterpolationMethod(im, method)) { im_scaled = gdImageScale(im, new_width, new_height); } + gdImageSetInterpolationMethod(im, old_method); if (im_scaled == NULL) { RETURN_FALSE; diff --git a/ext/gd/tests/bug73272.phpt b/ext/gd/tests/bug73272.phpt new file mode 100644 index 0000000...3bb710c --- /dev/null +++ b/ext/gd/tests/bug73272.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #73272 (imagescale() is not affected by, but affects imagesetinterpolation()) +--SKIPIF-- +<?php +if (!extension_loaded('gd')) die('skip gd extension not available'); +?> +--FILE-- +<?php +require_once __DIR__ . DIRECTORY_SEPARATOR . 'func.inc'; + +$src = imagecreatetruecolor(100, 100); +imagefilledrectangle($src, 0,0, 99,99, 0xFFFFFF); +imageellipse($src, 49,49, 40,40, 0x000000); + +imagesetinterpolation($src, IMG_NEAREST_NEIGHBOUR); +imagescale($src, 200, 200, IMG_BILINEAR_FIXED); +$dst = imagerotate($src, 60, 0xFFFFFF); + +test_image_equals_file(__DIR__ . DIRECTORY_SEPARATOR . 'bug73272.png', $dst); +?> +===DONE=== +--EXPECT-- +The images are equal. +===DONE=== diff --git a/ext/gd/tests/bug73272.png b/ext/gd/tests/bug73272.png new file mode 100644 index 0000000..97bfadf Binary files /dev/null and b/ext/gd/tests/bug73272.png differ

« previous php.cvs (#94877) next »