Imagick max resource differs in php script from php commandline

Viewed 364

I've changed my policy.xml to allow a larger max image sizes. When running the script in command line:

$ php image.php
64000

But then when I load it in the browser:

16000

The script simply contains:

<?php echo Imagick::getResourceLimit(9);

How can I make the same policy apply to the script served?

Edit: Answer multiple comments:

So the policy file is /etc/ImageMagick-6/policy.xml located with find /usr /opt / -name policy.xml. The server is nginx and it's a DigitalOcean droplet so I have full control.

I've tried setting the resource limit both prior to instantiating Imagick and after, both return the same 16000 limit.

Both running the file in commandline and the browser has been done on the server only.

Here's my adjusted policy file, i've bumped it all up incase any of them were causing the limit. The max file size for an image is 2GB and approx 32000px at 300dpi (it's for print):

  <policy domain="resource" name="memory" value="1GB"/>
  <policy domain="resource" name="map" value="1GB"/>
  <policy domain="resource" name="width" value="64KB"/>
  <policy domain="resource" name="height" value="64KB"/>
  <policy domain="resource" name="area" value="1GB"/>
  <policy domain="resource" name="disk" value="2GB"/>
1 Answers

On my version CLI and Nginx use different ini files.

CLI uses /etc/php/{version}/cli/php.ini and Nginx uses FPM /etc/php/{version}/fpm/php.ini, my guess would be you config is similar.

If they are, make sure the values you want to match do.

You can easily check; create a file containing phpinfo(); and check the path of your ini file from both CLI and a web browser.

Related