#23177 [Bgs->Opn]: imagecreatefromgd2 consumes too much memory

From: Date: Tue, 15 Apr 2003 07:04:26 +0000
Subject: #23177 [Bgs->Opn]: imagecreatefromgd2 consumes too much memory
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-37691@lists.php.net to get a copy of this message
ID: 23177 User updated by: alberty at neptunelabs dot de Reported By: alberty at neptunelabs dot de -Status: Bogus +Status: Open Bug Type: GD related Operating System: i686-pc-linux-gnu PHP Version: 4CVS-2003-04-12 (stable) New Comment: Hi Ilia, you have declared this bug report #23177 as bogus, but I don’t understand your calculation: 4932 x 3543 x 3 = 50 MB 4932 x 3543 x 4 = 67 MB Also you ignore the reported wrong error display in php: >> (tried to allocate 22581552 bytes) = 22 MB ?! Your calculation is only correct if you reserve an integer for each channel instead of a byte. Best regards, -- Steve Alberty Previous Comments: ------------------------------------------------------------------------ [2003-04-14 19:47:56] iliaa@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php The memory allocation is: width * height * channels, which in your case would be upwards of 200megs. ------------------------------------------------------------------------ [2003-04-12 07:59:56] alberty at neptunelabs dot de Hi, i've found a bug with handling gd2 images. The problem is affected with the bundled libgd (2.0.12). I've convert an image (4932x3543 pixel) with the pngtogd2 tool: ./pngtogd2 mytestpic.png mytestpic.gd2 4932 2 My memory limit is (php.ini): memory_limit = 162M The script: <?php $filename='mytestpic.gd2'; $image=imagecreatefromgd2($filename); ?> results an wrong error message: Fatal error: Allowed memory size of 169869312 bytes exhausted at (null):0 (tried to allocate 22581552 bytes) At first, 22581552 bytes is only the filesize of the mytestpic.gd2 file. Also it shouldn be a problem to load an image with 4932x3543 pixel, because this image need no more than 69896304 bytes (3+1 channels). Regards, Steve ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=23177&edit=1

« previous php.bugs (#37691) next »