Bug #77982 [NEW]: Valid PNG file does not resize and outputs a strange error
| From: | mark at kreine dot com | Date: | Tue, 07 May 2019 15:10:05 +0000 |
| Subject: | Bug #77982 [NEW]: Valid PNG file does not resize and outputs a strange error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-220744@lists.php.net to get a copy of this message | ||
From: mark at kreine dot com
Operating system: CentOS 7
PHP version: 7.3.5
Package: GD related
Bug Type: Bug
Bug description:Valid PNG file does not resize and outputs a strange error
Description:
------------
I'm trying to resize a PNG file. Instead of an actual resizing, I can
see a very strange error, which perhaps has nothing to do with my code.
The file that I use is here: https://imgur.com/vjnDpJq
I have myself opened GIMP and draw this, so this cannot be invalid PNG
file.
This is the error that's being always reproduced:
[Tue May 07 16:58:42.573572 2019] [php7:warn] [pid 7539:tid
140392702551808] [client 127.0.0.1:42140] PHP Warning:
imagecreatefrompng(): gd-png error: cannot allocate libpng main struct
in /var/www/sites/photogallery/index.php on line 7
Here is a configure string, which was used in order to compile PHP:
./configure --prefix=/soft/php --with-apxs2=/soft/httpd/bin/apxs
--with-libxml-dir=/soft/libxml --with-png-dir=/soft/libpng
--with-curl=shared,/soft/curl --with-bz2=shared,/soft/bzip
--with-mysqli=shared,/soft/mysql/bin/mysql_config
--with-gettext=shared,/soft/gettext --with-pcre-dir=/soft/pcre
--with-jpeg-dir=/soft/libjpeg --with-gd=shared
--with-zlib=shared,/soft/zlib --with-pdo-mysql=shared,/soft/mysql
--enable-calendar --enable-mbstring --enable-bcmath --enable-ftp
--enable-zip --enable-soap --enable-exif --enable-intl --enable-sockets
Test script:
---------------
function resizePng($new_width, $new_height)
{
$file = "/var/www/sites/photogallery/image.png";
$im = imagecreatefrompng($file);
$imnew = imagecreatetruecolor($new_width, $new_height);
imagecopyresized($imnew, $im, 0, 0, 0, 0, $new_width, $new_height,
1920, 1080);
header("Content-type: image/png");
imagepng($imnew);
}
Expected result:
----------------
Resized PNG which is to be outputted in browser.
Actual result:
--------------
An error as follows:
[Tue May 07 16:58:42.573572 2019] [php7:warn] [pid 7539:tid
140392702551808] [client 127.0.0.1:42140] PHP Warning:
imagecreatefrompng(): gd-png error: cannot allocate libpng main struct
in /var/www/sites/photogallery/index.php on line 7
--
Edit bug report at https://bugs.php.net/bug.php?id=77982&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77982&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77982&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77982&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77982&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77982&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77982&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77982&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77982&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77982&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77982&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77982&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77982&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77982&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77982&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77982&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77982&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77982&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77982&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77982&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77982&r=mysqlcfg