PHP from memory, but why?

I have the following line of code at the beginning of the function:

$src_img=imagecreatefromjpeg($name); 

$name contains the full path to the folder, inaccessible to the public, which contains the image, which is a JPG 4.4 MB.

Usually, when this problem occurs, PHP needs more memory than is allocated to open the compressed image, and issuing the ini_set to raise the member to 128 MB solves the problem. However, in this case this is not so. I tried upgrading to 256, 512, and 1024 MB, and yet it returns with an error:

Fatal error: the allowed memory size of 262144 bytes has been exhausted (tried to allocate 17152 bytes) in /imgprocess.php on line 83.

I even tried to use (smuggling!) -1 to allow unlimited memory, just to see, something makes it go high, but still not go.

I tried another image file because it was bad jpg but still not.

How can this be solved?

EDIT: I have to add that PHP is not in safe mode

+4
source share
1 answer

This should solve your problem:

 ini_set('memory_limit', '256m'); 

Please read faq.using.shorthandbytes

Using "MB" is the wrong abbreviated notation. ini_get () does not return normalized values, most often returns what it was set to.

+2
source

Source: https://habr.com/ru/post/1400742/


All Articles