简体   繁体   中英

Increasing Imagicks max resolution

I have a client who allows customers to upload large files to manipulate for printing. The site's using Imagick to handle the image, however, when trying to set the max width and height, it wont go any higher than 16000. For example:

// This sets the max width to 20000px
php > Imagick::setResourceLimit(9, 20000);
php > echo $image->getResourceLimit(9);
16000

php > Imagick::setResourceLimit(9, 15000);
php > echo $image->getResourceLimit(9);
15000

Is this a limitation of the library or is there something else I need to be configuring?

You need to find your policy.xml for ImageMagick and uncomment and set up the lines that look like this:

<!-- <policy domain="resource" name="memory" value="2GiB"/> -->
<!-- <policy domain="resource" name="width" value="10KP"/> -->
<!-- <policy domain="resource" name="height" value="10KP"/> -->

You should be able to find the file with:

identify -list configure | grep CONFIGURE_PATH

Sample Output

CONFIGURE_PATH /usr/local/Cellar/imagemagick/7.0.8-10/etc/ImageMagick-7/

then append policy.xml to the end of that. So mine is:

/usr/local/Cellar/imagemagick/7.0.8-10/etc/ImageMagick-7/policy.xml

If, for some reason you cannot find the policy.xml file by the method above, you can search for it the long (slower) way with:

find  /usr  /opt /  -name policy.xml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM