note 73546 added to function.imagecreatefrompng
| From: | marcos at assl-site dot net | Date: | Wed, 28 Feb 2007 20:23:27 +0000 |
| Subject: | note 73546 added to function.imagecreatefrompng | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-123962@lists.php.net to get a copy of this message | ||
I had the same problem as jboyd1189 at yahoo dot com but I solve d it allocating more memory
dynamically.
Usually the memory_limit var on php.ini is set to 8M. Unfortunately, the required amount of memory
to manage a PNG image about 1000x1000 could be bigger !
The approach I used to solve the problem is:
1-Calculate the memory required by the image
2-Set the new memory_limit value
3-Create the PNG image and thumbnail
4-Restore the original value
1-The following value works for me:
$required_memory = Round($width * $height * $size['bits']);
Note that for JPEG the requirements are not the same:
http://es2.php.net/manual/en/function.imagecreatefromjpeg.php#60241
2-Use somthing like:
$new_limit=memory_get_usage() + $required_memory;
ini_set("memory_limit", $new_limit);
4-ini_restore ("memory_limit");
----
Server IP: 130.206.1.5
Probable Submitter: 85.48.225.245
----
Manual Page -- http://www.php.net/manual/en/function.imagecreatefrompng.php
Edit -- https://master.php.net/note/edit/73546
Del: integrated -- https://master.php.net/note/delete/73546/integrated
Del: useless -- https://master.php.net/note/delete/73546/useless
Del: bad code -- https://master.php.net/note/delete/73546/bad+code
Del: spam -- https://master.php.net/note/delete/73546/spam
Del: non-english -- https://master.php.net/note/delete/73546/non-english
Del: in docs -- https://master.php.net/note/delete/73546/in+docs
Del: other reasons-- https://master.php.net/note/delete/73546
Reject -- https://master.php.net/note/reject/73546
Search -- https://master.php.net/manage/user-notes.php