Reputation: 4141
I know there are tons of questions regarding this problem. But I still couldn't understand the cause. The error shows when I add resize function.
Image::make($logo)->resize(200*200)->save(public_path('Uploads/logo/' . $fileName));
Otherwise it works fine. Why would a function tries to consume that amount of memory?
Upvotes: 2
Views: 1732
Reputation: 1188
Increase the amount of variable memory_limit = 128M
in php.ini to your applications demand. It might be 256M/512M/1048M.....
Upvotes: 1
Reputation: 717
Resizing can use a lot of memory. Maybe in this case the original image is big. You can try to flatten it first to a JPG and then resize it.
To increase the memory limit you can add this on top of the PHP script:
ini_set('memory_limit', '2G');
Upvotes: 0
Reputation: 2126
When you do ->resize(200*200)
you are not resizing the image to 200 pixels by 200 pixels, you are passing the width (first parameter of the resize() function) as 200 times 200, which is 40,000, hence the memory problem.
You need to do:
Image::make($logo)->resize(200, 200)->save(public_path('Uploads/logo/' . $fileName));
Upvotes: 5