Reputation: 147
I use laravel intervention to create image with watermark, but i found laravel intervention cannot handle image more than 2mb, here is my code:
// open an image file
$img = Image::make('msg-1-fc-40.jpg')->encode('jpg', 75);
$img->fit(250, 250, function ($constraint) {
$constraint->aspectRatio();
});
// finally we save the image as a new file
$img->save('test.jpg');
How can i process the image more than 2mb?
Upvotes: 0
Views: 431
Reputation: 592
Image operations tend to be quite memory exhausting because image handling libraries usually 'unpack' all the pixels to memory.
A JPEG file of 3MB can thus easily grow to 60MB in memory and that's when you've probably hit the memory limit allocated for PHP.
As far I remember, XAMP only allocates 128 MB RAM for PHP.
Check your php.ini and increase the memory limit, e.g.:
memory_limit = 512MB
Then restart the server.
But this is not a good approach, the best approach is to compress and resize any image before saving it to the server.
Upvotes: 1