Reputation: 217
I have the following line of code, at the start of a function:
$src_img=imagecreatefromjpeg($name);
the $name
contains the full server path to the non-publically accessible folder that contains the image, which is a 4.4MB JPG.
Normally when this problem has occurred, PHP needs more memory than is allocated to open the compressed image, and issuing a ini_set
command to raise the member to 128MB solves the problem. However, in this case, it does not. I've tried raising to 256, 512 and 1024MB and still it comes back with an error:
Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 17152 bytes) in /imgprocess.php on line 83.
I've even tried using the (contraband!) -1 to allow unlimited memory, just to see if something was causing it to go sky high, but still no go.
I've tried a different image file incase it was a bad JPG, still no go.
How can this be solved?
EDIT: I should add that PHP isn't in Safe Mode
Upvotes: 4
Views: 325
Reputation: 1073
This should solve your problem:
ini_set('memory_limit', '256m');
Please read faq.using.shorthandbytes
Using "MB" is a wrong shorthand notation. ini_get() doesn't return normalized values most often it returns what it was set to.
Upvotes: 2