php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79676 imagescale adds black border with IMG_BICUBIC
Submitted: 2020-06-04 16:26 UTC Modified: 2020-06-05 14:51 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: rubik99 at pokemail dot net Assigned: cmb (profile)
Status: Closed Package: GD related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
 [2020-06-04 16:26 UTC] rubik99 at pokemail dot net
Description:
------------
imagescale adds a bottom and right black border if the mode used is IMG_BICUBIC

This is dependant on the GD version not PHP version

GD versions that fail:
The official Windows php.exe (7.4.5) uses GD "bundled (2.1.0 compatible)"
The official Windows php.exe (7.2.30) uses GD "bundled (2.1.0 compatible)"
http://phpfiddle.org/ (PHP 7.1.18) uses GD "bundled (2.1.0 compatible)"
One of my site hosts (PHP 7.0.33) uses GD "bundled (2.1.0 compatible)"

GD versions that pass:
https://rextester.com/ (PHP 7.2.24) uses GD 2.2.5
https://paiza.io/ (PHP 7.4.1) uses GD 2.2.5
https://www.tutorialspoint.com/ (PHP 7.1.8) uses GD 2.2.4

LibGD 2.3.0 (March 2020) contains security fixes
PHP 7.4.5 source file "ext/gd/libgd/gd.h" defines GD version as 2.0.35 (<=2015)










Test script:
---------------
function test($image, $desc) {
echo $desc . ' - Test Result: ' . (imagecolorat($image, imagesx($image) - 1 , imagesy($image) - 1) != 0x000000 ? 'pass' : 'fail') . '<br>';
//line below displays image
//ob_start(); imagepng($image); $imageString = ob_get_clean();echo '<img src="data:image/png;base64, ' . base64_encode($imageString) . '" /><br><br>';
}
echo 'PHP: ' . phpversion(). ' GD: ' . gd_info()["GD Version"] . '<br>';
$size = 32;
$src = imagecreatetruecolor($size, $size);
imagefilledrectangle($src, 0, 0, $size - 1 , $size - 1, 0xff00ff);//magenta
test($src, 'No scaling');
test(imagescale($src, $size * 2, $size * 2), 'Scale 200%, default mode');
test(imagescale($src, $size / 2, $size / 2), 'Scale 50%, default mode');
test(imagescale($src, $size * 2, $size * 2, IMG_BICUBIC), 'Scale 200%, IMG_BICUBIC mode');
test(imagescale($src, $size / 2, $size / 2, IMG_BICUBIC), 'Scale 50%, IMG_BICUBIC mode');


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-06-04 16:33 UTC] rubik99 at pokemail dot net
I am new to PHP and GD
I was unsure if php_gd2.dll included in Windows versions is a PHP-specific dll or just a very old official GD dll.
This bug has obviously been fixed in actual GD.
Cannot find information on using latest GD with PHP (I have no compiler available) so am dependant on official PHP windows download
Also confused why PHP bundles old GD version with known security bugs
 [2020-06-04 17:08 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-06-05 14:51 UTC] cmb@php.net
-Status: Assigned +Status: Verified
 [2020-06-05 14:51 UTC] cmb@php.net
> I was unsure if php_gd2.dll included in Windows versions is a
> PHP-specific dll or just a very old official GD dll.

That is the PHP GD extension which also includes the bundled
libgd.

> Also confused why PHP bundles old GD version with known security
> bugs

Well, the version information for PHP's bundled libgd is bogus
(known issue). It is only relevant that it is the bundled libgd,
and in that case PHP's version is relevant.

The point is that both bundled and external libgd have been
developed somewhat independently, and only the bundled libgd is
integrated with the Zend memory manager.  We are doing our best to
keep (or better to bring) them in sync.  This is particurlary hard
for (parts of) gd_interpolation.c, which have rather different
implementations in bundled and external libgd.
 [2020-06-05 14:51 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #79676: imagescale adds black border with IMG_BICUBIC
On GitHub:  https://github.com/php/php-src/pull/5667
Patch:      https://github.com/php/php-src/pull/5667.patch
 [2020-06-06 14:20 UTC] rubik99 at pokemail dot net
Understood. Thank you for the information and quick fix.
 [2020-06-12 12:10 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=86e1f0ea1197e878a657288562d0a11d6f427a18
Log: Fix #79676: imagescale adds black border with IMG_BICUBIC
 [2020-06-12 12:10 UTC] cmb@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC