imagemagick time limit

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
gabriel

imagemagick time limit

Post by gabriel »

Is there a posibility to set a timeout (time limit) for imagemagick (convert in special)?. I have seen limitations for disk, memory ...., but not for time.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

IM itself will probably never have such a limit, as it could only practically do it between 'options' and not during a actual processing step, and it is the processing step that can take a long time. It also can be locked up in a I/O call, which is has no control over.

You can however do a timeout in the calling program!!!

For example I can do this in a bourne/bash shell..

Code: Select all

TIMEOUT=60
timeout_convert() {
  # lookup the users disk quota but with a timeout
  convert "$@" &
  # now ensure that the above command does not run too long
  cmd_pid=$!
  ( sleep $TIMEOUT
    echo >&2 "Quota Timeout"
    kill -9 $cmd_pid 2>/dev/null
  ) &
  kill_pid=$!
  wait $cmd_pid
  kill $kill_pid 2>/dev/null
}
You can see more about this and other tries to do this in my shell script notes
http://www.cit.gu.edu.au/~anthony/info/ ... ript.hints
and look for "Command timeout". Other API's have other simular methods.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply