Reputation: 85
I use PHP and Imagick extension for resize a photo (about 5000x7000):
$img = new Imagick($fn);
$img->thumbnailImage($width, 0);
It works for $width
is 800, 900 ... 1300,
but it crashes for 1400 and 1600: cache resources exhausted /app/photo.jpg' @ error/cache.c/OpenPixelCache/4083
.
I assumed it depends on the width and the result image size. And googling for the error text confirmed my guesses. They advise to increase memory limits in ImageMagick config.
But! I tried to create image with the width is 2000 and it worked correctly!
1400, 1600, 1800 - fail. 1900, 2000, 2100... - success.
I'm lost.
Upvotes: 3
Views: 9897
Reputation: 1690
Increase the amount of resources that ImageMagick may use. You can control how many resources ImageMagick may use by editing the policy.xml
file. See the documentation on security policy.
On my (Debian Linux) system the configuration is located at /etc/ImageMagick-6/policy.xml
. See here for different locations on various operating systems.
I changed the following settings to 2GiB
to get rid of the error, you may need different ones, depending on your needs and system resources. Take a look at the documentation.
<policy domain="resource" name="memory" value="2GiB"/>
<policy domain="resource" name="map" value="2GiB"/>
Upvotes: 19