How to disable policy on case by case basis?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
syl_leroux
Posts: 18
Joined: 2017-04-12T09:05:38-07:00
Authentication code: 1151

How to disable policy on case by case basis?

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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.
snibgo's IM pages: im.snibgo.com
syl_leroux
Posts: 18
Joined: 2017-04-12T09:05:38-07:00
Authentication code: 1151

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

Post 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?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo »

Yes. Or create another installation of IM, with its own policy.xml.
snibgo's IM pages: im.snibgo.com
syl_leroux
Posts: 18
Joined: 2017-04-12T09:05:38-07:00
Authentication code: 1151

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

Post 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.
Post Reply