#35348 [Fbk->Bgs]: imagecreatefrompng causes memory exhaust error
| From: | pajoye@php.net | Date: | Wed, 23 Nov 2005 12:58:20 +0000 |
| Subject: | #35348 [Fbk->Bgs]: imagecreatefrompng causes memory exhaust error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-88782@lists.php.net to get a copy of this message | ||
ID: 35348
Updated by: pajoye@php.net
Reported By: dtra at faceyoursfears dot com
-Status: Feedback
+Status: Bogus
Bug Type: GD related
Operating System: fedora core 4 linux
PHP Version: 5.1.0RC6
-Assigned To:
+Assigned To: pajoye
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
No matter the size it is a memory limit problem
('--enable-memory-limit'), increase the max values or does not use it
if you do not know what it does.
--Pierre
Previous Comments:
------------------------------------------------------------------------
[2005-11-23 12:37:30] tony2001@php.net
How big is this image (Screenshot.png)?
------------------------------------------------------------------------
[2005-11-23 12:31:21] dtra at faceyoursfears dot com
sorry, it says line 5 in the error output, it's the line that says $i =
imagecreatefrompng($file);
------------------------------------------------------------------------
[2005-11-23 12:28:28] dtra at faceyoursfears dot com
Description:
------------
i am just trying to resize an image on my computer, using the gd
library, imagecreatefrompng gives me this errorFatal
i have 777 chmodded all directories and files
gd is the bundled gd library installed as a shared module
imagecreatefromjpeg, using exactly the same code works fine
'./configure' '--build=i386-redhat-linux' '--host=i386-redhat-linux'
'--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr'
'--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin'
'--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include'
'--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var'
'--sharedstatedir=/usr/com' '--mandir=/usr/share/man'
'--infodir=/usr/share/info' '--cache-file=../config.cache'
'--with-libdir=lib' '--with-config-file-path=/etc'
'--with-config-file-scan-dir=/etc/php.d' '--disable-debug'
'--with-pic'
'--disable-rpath' '--with-bz2' '--with-curl'
'--with-exec-dir=/usr/bin'
'--with-freetype-dir=/usr' '--with-png-dir=/usr'
'--enable-gd-native-ttf' '--without-gdbm' '--with-gettext'
'--with-gmp'
'--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl'
'--with-png'
'--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib'
'--with-layout=GNU' '--enable-exif' '--enable-ftp'
'--enable-sockets'
'--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg'
'--enable-track-vars' '--enable-trans-sid' '--enable-yp'
'--enable-wddx' '--with-pear=/usr/share/pear' '--with-kerberos'
'--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr'
'--enable-memory-limit' '--enable-shmop' '--enable-calendar'
'--enable-dbx' '--enable-dio'
'--with-mime-magic=/etc/httpd/conf/magic'
'--without-sqlite' '--with-libxml-dir=/usr' '--with-xml'
'--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd'
'--without-odbc' '--disable-dom' '--disable-dba'
'--without-mysqli'
additional ini files parsed
/etc/php.d/dom.ini, /etc/php.d/ffmpeg.ini, /etc/php.d/gd.ini,
/etc/php.d/mysql.ini, /etc/php.d/mysqli.ini, /etc/php.d/pdo.ini,
/etc/php.d/pdo_mysql.ini, /etc/php.d/soap.ini, /etc/php.d/xsl.ini
----added to php.ini-------
[mime_magic]
mime_magic.debug = 1
mime_magic.magicfile = "/usr/share/file/magic.mime"
Reproduce code:
---------------
$file = '/path/to/Screenshot.png';
$path = '/var/www/html/images/temp.png';
$type = mime_content_type($file);
$i = imagecreatefrompng($file);
list($width, $height) = getimagesize($file);
if ($width > $height) $scale = $width / 260;
else $scale = $height / 240;
$imgWidth = round($width/$scale, 0);
$imgHeight = round($height/$scale, 0);
$newI = imagecreatetruecolor($imgWidth, $imgHeight);
$bgColor = imagecolorallocate($newI, 51, 85, 204);
imagefilledrectangle($newI, 0, 0, $imgWidth, $imgHeight, $bgColor);
imagecopyresampled($newI, $i, 0, 0, 0, 0, $imgWidth, $imgHeight,
$width, $height);
if ($type == 'image/jpeg') imagejpeg($finalImg, $path, 70);
else if ($type == 'image/x-png' || $type == 'image/png')
imagepng($finalImg, $path, 70);
header('Content-type: image/png');
imagepng($path);
Expected result:
----------------
prints the newly resized and created image to the screen
Actual result:
--------------
error: Allowed memory size of 8388608 bytes exhausted (tried to
allocate 5242880 bytes) in /var/www/html/tmp/png-img.php on line 5
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35348&edit=1