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
Montage hangs - specifying a time out?
-
- Posts: 6
- Joined: 2010-12-05T06:06:56-07:00
- Authentication code: 8675308
Re: Montage hangs - specifying a time out?
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.
-
- Posts: 6
- Joined: 2010-12-05T06:06:56-07:00
- Authentication code: 8675308
Re: Montage hangs - specifying a time out?
Actually did not work. Problem is still occurring. Here is a screen shot of the memory usage Im seeing:
http://cl.ly/1Y0r311Q0M0q0e0o1F1t
Thoughts?
http://cl.ly/1Y0r311Q0M0q0e0o1F1t
Thoughts?
Re: Montage hangs - specifying a time out?
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).
-
- Posts: 6
- Joined: 2010-12-05T06:06:56-07:00
- Authentication code: 8675308
Re: Montage hangs - specifying a time out?
Great thanks, but since I have no idea what is causing this any idea which resource setting should be set?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Montage hangs - specifying a time out?
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.)
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.)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/