Page 1 of 1

Montage hangs - specifying a time out?

Posted: 2010-12-05T06:32:59-07:00
by mrblackman
I have a fairly interesting ruby script that uses ImageMagick to create a montage image of randomly selected photos from my iPhoto library. It works great 80% of the time and Ive been running it for almost a year, but something that has always bugged me is when montage crashes. Basically, for whatever reason, montage cannot handle the photos selected and simply hangs eating up resources.

Here is a sample line that is called:

montage -size #{WIDTH}x#{HEIGHT} null: '#{@path}/*.JPG' '#{@path}/*.jpg' null: -thumbnail 200x200 -bordercolor Lavender \
-background black +polaroid -background #{bg_color} -geometry -10+2 '#{@filename}'

Does anyone have any idea what would cause ImageMagick to hang when processing and is there a way to specify a time out for montage so if it cant process an image after XX seconds it will just quit?

Thanks,

Josh

Re: Montage hangs - specifying a time out?

Posted: 2010-12-05T07:59:00-07:00
by magick
See http://www.imagemagick.org/script/resources.php. Set the time policy in the policy.xml configuration file or the MAGICK_TIME_LIMIT environment variable.

Re: Montage hangs - specifying a time out?

Posted: 2010-12-09T07:08:08-07:00
by mrblackman
Actually did not work. Problem is still occurring. Here is a screen shot of the memory usage Im seeing:

http://cl.ly/1Y0r311Q0M0q0e0o1F1t

Thoughts?

Re: Montage hangs - specifying a time out?

Posted: 2010-12-09T07:15:29-07:00
by magick
Read http://www.imagemagick.org/script/architecture.php and http://www.imagemagick.org/script/resources.php. Setting resources and policies should solve your problem. We host http://www.imagemagick.org/MagickStudio ... Studio.cgi which has processed over a million images over more than 10 years and we have not had a resource problem due to carefully setting the various resource limit available to ImageMagick. Take a look at http://trac.imagemagick.org/browser/MagickStudio in particular MagickStudio.cgi and MagickStudio.pm to see how we stop run-away jobs (too much resource, too much time).

Re: Montage hangs - specifying a time out?

Posted: 2010-12-09T07:19:41-07:00
by mrblackman
Great thanks, but since I have no idea what is causing this any idea which resource setting should be set?

Re: Montage hangs - specifying a time out?

Posted: 2010-12-09T16:57:33-07:00
by anthony
I am not certain how IM ternimates when a time limit is reached (does it setup a time interrupt?)

However if you like a non-IM method of timing out any general command then...

Look at my shell script hints file...
http://www.ict.griffith.edu.au/~anthony ... ript.hints
and look for "Command timeout" and specifically "Attempt 3"

I use this myself to terminate nslookup's that hang due to network work problems.
However the notes are written by me, for me, so may be a little terse for others.

Similar methods should be possible in other API languages. (Ruby, Perl, etc.)