Page 1 of 1

How to disable policy on case by case basis?

Posted: 2018-08-14T07:51:53-07:00
by syl_leroux
Hi everyone,

Is there a way to disable the "memory" policy for a specific instance of `convert` without affecting other applications using ImageMagick?

More specifically, I have a large amount of PNG image to convert to an animated gif. This is a one-shot operation--and the workstation has more than enough ram to hold the data in main memory. But `convert` insists in "caching" the data beyond the first few MiB to the /tmp directory. Which is useless here.

I assume this was caused by the default policy file (which I don't want to change):

Code: Select all

sylvain@bulbizarre:/local/sylvain/d1d2f730467857fa3afe$ cat /etc/ImageMagick-6/policy.xml 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policymap [
<!ELEMENT policymap (policy)+>
<!ELEMENT policy (#PCDATA)>
<!ATTLIST policy domain (delegate|coder|filter|path|resource) #IMPLIED>
<!ATTLIST policy name CDATA #IMPLIED>
<!ATTLIST policy rights CDATA #IMPLIED>
<!ATTLIST policy pattern CDATA #IMPLIED>
<!ATTLIST policy value CDATA #IMPLIED>
]>
<policymap>
  <!-- <policy domain="resource" name="temporary-path" value="/tmp"/> -->
  <policy domain="resource" name="memory" value="256MiB"/>
  <policy domain="resource" name="map" value="512MiB"/>
  <policy domain="resource" name="width" value="16KP"/>
  <policy domain="resource" name="height" value="16KP"/>
  <policy domain="resource" name="area" value="128MB"/>
  <policy domain="resource" name="disk" value="1GiB"/>
  <!-- <policy domain="resource" name="file" value="768"/> -->
  <!-- <policy domain="resource" name="thread" value="4"/> -->
  <!-- <policy domain="resource" name="throttle" value="0"/> -->
  <!-- <policy domain="resource" name="time" value="3600"/> -->
  <!-- <policy domain="system" name="precision" value="6"/> -->
  <!-- not needed due to the need to use explicitly by mvg: -->
  <!-- <policy domain="delegate" rights="none" pattern="MVG" /> -->
  <!-- use curl -->
  <policy domain="delegate" rights="none" pattern="URL" />
  <policy domain="delegate" rights="none" pattern="HTTPS" />
  <policy domain="delegate" rights="none" pattern="HTTP" />
  <!-- in order to avoid to get image with password text -->
  <!--<policy domain="path" rights="none" pattern="@*"/>-->
  <policy domain="path" rights="read" pattern="@/tmp/*"/>
  <policy domain="cache" name="shared-secret" value="passphrase" stealth="true"/>
</policymap>


I tried to launch `convert` by changing the MAGICK_MAP_LIMIT, MAGICK_MEMORY_LIMIT and MAGICK_AREA_LIMIT settings in various combination without any success apparently. Same thing using the `-limit memory 1GiB ` command line option.

Re: How to disable policy on case by case basis?

Posted: 2018-08-14T08:20:59-07:00
by snibgo
policy.xml sets limits that can't be relaxed. Other mechanisms such as MAGICK_MEMORY_LIMIT apply extra limits, in addition to limits imposed by policy.xml.

Re: How to disable policy on case by case basis?

Posted: 2018-08-14T08:29:34-07:00
by syl_leroux
policy.xml sets limits that can't be relaxed.
I was afraid of that.

Does that mean if I need more resources to handle an exceptional use case, I must relax the policy for the whole system first?

Re: How to disable policy on case by case basis?

Posted: 2018-08-14T09:51:55-07:00
by snibgo
Yes. Or create another installation of IM, with its own policy.xml.

Re: How to disable policy on case by case basis?

Posted: 2018-08-14T10:05:05-07:00
by syl_leroux
Thnaks for the idea @snibgo:
Or create another installation of IM, with its own policy.xml.
I will do that. Or maybe run the current install in a chrooted environment.