6

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"/>
Jam3sn
  • 1,077
  • 4
  • 17
  • 35
  • Could you add the policy.xml change you did here (not the whole file, just the changed config line). You may need to resort to setting it on the fly with [setResourceLimit](http://php.net/manual/en/imagick.setresourcelimit.php) .. the config between command line php and apache php, can be different at times. – IncredibleHat Sep 04 '18 at 16:10
  • Where did you edit your policy.xml -- in what directory? If your hosting provide set it to some value, then you can only make it more strict and not less strict. – fmw42 Sep 04 '18 at 16:14
  • Were you running both on the same computer? Or one locally and the other on a server? – fmw42 Sep 04 '18 at 16:55
  • I've edited my post to inlude these – Jam3sn Sep 05 '18 at 08:25
  • any ideas? @IncredibleHat – Jam3sn Sep 06 '18 at 10:08

1 Answers1

0

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.

Alexander Holman
  • 929
  • 9
  • 21