Limiting the time of any ImageMagick command

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
Carter J
Posts: 116
Joined: 2013-12-19T02:20:09-07:00
Authentication code: 6789

Limiting the time of any ImageMagick command

Post by Carter J »

Hi,

We are trying to limit the elapsed time of ImageMagick commands, but we are failing in limiting them.

We have used the following link as reference:
http://www.imagemagick.org/script/resources.php

With reference to the above link we included the below line in policy.xml file(For limiting the time of ImageMagick command to 20 secs).
<policy domain="resource" name="time" value="20"/>

And even defined an environment variable "MAGICK_TIME_LIMIT" as 20

But ImageMagick command is not exiting even after 20 secs also.

Machine Details:
Linux 2.6.32-279.9.1.el6.x86_64 #1 x86_64 x86_64 x86_64 GNU/Linux
Red Hat Enterprise Linux Server release 6.3

Please let us know if we miss any configuration.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Limiting the time of any ImageMagick command

Post by snibgo »

What version of IM? A test works fine for me on v6.9.2-5 on Windows 8.1.

What commands have you tried? IM can't set a resource limit on external delegates like Ghostscript. I'm not sure about internal delegates.
snibgo's IM pages: im.snibgo.com
Carter J
Posts: 116
Joined: 2013-12-19T02:20:09-07:00
Authentication code: 6789

Re: Limiting the time of any ImageMagick command

Post by Carter J »

Thanks for the response @snibgo.

IM Version:
Version: ImageMagick 6.9.1-0 Q16 x86_64 2015-03-30 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype jng jpeg lcms ltdl lzma pangocairo png tiff x xml zlib

Sample Commands:

Identify Command:
identify -format "Profile-icc: %[profile:icc]---Colorspace: %[colorspace]" "Upload_Test_09062016_22.pdf"

Convert Command:
convert -flatten -alpha off -units pixelsperinch "Upload_Test_09062016_26.pdf[0]" -profile "/configuration/ICCProfiles/Recommended/sRGB Color Space Profile.icm" "Upload_Test_09062016_26.pdf.jpg"
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Limiting the time of any ImageMagick command

Post by snibgo »

Both your commands read PDF files. This is delegated to Ghostscript, an external program. ImageMagick doesn't set resource limits on external delegates.
snibgo's IM pages: im.snibgo.com
Post Reply