Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

freel's avatar

Intervention/image memory_limit

Hello team, I need your help. 4 hours tying to understand one thing. I am using Intervention/image memory_limit I have 128M

Problem is that when I am trying to open file. I am getting error 500.

$file_name = $request->file('myImage');
Image::make($file_name)->resize(300, 200)->save('foo.jpg');

As I understand We a running out of memory. PHP error log: [07-Apr-2016 22:41:10 UTC] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 21248 bytes) in /Users/Freel/Desktop/Web/project22.dev/vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php on line 114

Question: I found somewhere in google that memory_limit can be max 128M, so how to solve this issue? how to make this library work?

Image files I am trying to convert is 5mb. Thanks

0 likes
8 replies
freel's avatar

Not sure what is fmp but, 128M was for last 3 months :) in my mac so I think i restarted that already few times. or I may be wrong.

Gerard's avatar
Gerard
Best Answer
Level 5

@freel I used this package in the past for an online image resizer and I had problems with memory limit too, I solved it with this simple line of code

public function resize(){
    ini_set('memory_limit','256M');
    # Do your Intervention/image operations...
}

As I remember, I didn't need to configure anything else. Maybe it's not a memory limit problem, but a file size limit. If you want, try to upload your image in my resizer app and tell me if something went wrong, otherwise try the method above.

8 likes
freel's avatar

Unbelievable!!!! Thank you, working!! :) you solved my 8 hours headache in one line :D

1 like
Gerard's avatar

Glad to help you @freel :) At its moment this gave me some headaches too.

ahmedrivaj's avatar

thank you it worked, i have tried changing max_limit in php.ini file and it didn't work.

aurawindsurfing's avatar

Same here! Thanks this fixes the Intervention issue!

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

I also tried

48M, 64M, 128M but all of them seem to run out of memory

Please or to participate in this conversation.