From:             dtra at faceyoursfears dot com
Operating system: fedora core 4 linux
PHP version:      5.1.0RC6
PHP Bug Type:     GD related
Bug description:  imagecreatefrompng causes memory exhaust error

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 bug report at http://bugs.php.net/?id=35348&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=35348&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=35348&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=35348&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=35348&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=35348&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=35348&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=35348&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=35348&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=35348&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=35348&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=35348&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=35348&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=35348&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=35348&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=35348&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=35348&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=35348&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=35348&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=35348&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=35348&r=mysqlcfg

Reply via email to