com php-src: Fixed Bug #65171 imagescale() fails: ext/gd/gd.c

From: Date: Wed, 15 Oct 2014 17:13:25 +0000
Subject: com php-src: Fixed Bug #65171 imagescale() fails: ext/gd/gd.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-82348@lists.php.net to get a copy of this message
Commit: 2728e6f01798b1146b41587d38bf84cdf9988d17 Author: Remi Collet <remi@php.net> Wed, 15 Oct 2014 19:13:25 +0200 Parents: 6d9c9f8f0468f8d90dc233d6fc70dc949349e6da Branches: PHP-5.5 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2728e6f01798b1146b41587d38bf84cdf9988d17 Log: Fixed Bug #65171 imagescale() fails Third param (height) is set as optional, but default value = -1 is incorrect Compute correct height to preserve ratio. Bugs: https://bugs.php.net/65171 Changed paths: M ext/gd/gd.c Diff: diff --git a/ext/gd/gd.c b/ext/gd/gd.c index cbc7219..f86dad5 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -5110,11 +5110,23 @@ PHP_FUNCTION(imagescale) return; } method = tmp_m; - new_width = tmp_w; - new_height = tmp_h; ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd); + if (tmp_h < 0) { + /* preserve ratio */ + long src_x, src_y; + + src_x = gdImageSX(im); + src_y = gdImageSY(im); + if (src_x) { + tmp_h = tmp_w * src_y / src_x; + } + } + + new_width = tmp_w; + new_height = tmp_h; + if (gdImageSetInterpolationMethod(im, method)) { im_scaled = gdImageScale(im, new_width, new_height); }

« previous php.cvs (#82348) next »