Page 1 of 1
[SOLVED]Help: creating contactsheet with imagemagic's montage
Posted: 2016-09-21T05:38:51-07:00
by t-boz
Hello everyone.
So I created contact sheet with image thumbnails, their filename and image sizes with the following command:
Code: Select all
montage -verbose -label '%wx%h\n%t' -font Helvetica -pointsize 10 -background '#FFFFFF' -fill 'gray' -geometry 200x200+2+2 -auto-orient *.jpg out.jpg
however when I run the script in the directory with A LOT of huge (in size) .jpg files, I quickly get out of memory, and entire computer freezes.
Adding -define jpeg:size=200x200 helps, however then incorrect image's sizes are added to label (width x height), and it's important that I have ORIGINAL image sizes on the final contact sheet.
Any help would be greatly appreciate!
Re: Help: creating contactsheet with imagemagic's montage
Posted: 2016-09-21T07:46:10-07:00
by snibgo
I would do the job in stages, using a temporary directory.
1. Create or empty the temp dir.
2. Convert each source file, labelling and resizing, to the temp dir. Run "convert" once per source file. Or perhaps you could do this with "mogrify".
3. Montage the temp dir files.
Re: Help: creating contactsheet with imagemagic's montage
Posted: 2016-09-21T12:14:56-07:00
by t-boz
thanks for the reply!
How would I then complete all into one single contact sheet image? Can you show on a simple example?
Re: Help: creating contactsheet with imagemagic's montage
Posted: 2016-09-21T12:50:26-07:00
by Bonzo
There are different ways you could do it; I do not use mogrify but something like this might work but you would need two steps.
Code: Select all
mogrify -label '%wx%h\n%t' -font Helvetica -pointsize 10 -fill 'gray' -background '#FFFFFF' -geometry 200x200+2+2 -auto-orient -format miff *.jpg
This should leave your original jpg images intact and save as a lossless format - make sure you test on some copy images as mogrify can overwrite the original.
You could also write a shell/batch script and loop over each image with convert.
Re: Help: creating contactsheet with imagemagic's montage
Posted: 2016-09-21T14:53:55-07:00
by t-boz
thanks so much for replying, but sadly it doesn't solve my problem at all.
yes, covert works, and fine (though image files only increase in size)
however when running a command to generate the contact sheet
I face the same problem. Imagemagick will read each file and keep the full size image in memory until montage is done. And with *.miff the size only increased, so it doesn't help at all, and I get stuck/memory full/computer frozen (please note, I have to run the bash script to create contact sheets against folders of hunderds of uncompressed .jpg files, sometimes each .jpg file over 100 MB. Of course when I have a folder with only 20-30 images (even large in size), it's all fine. But when there are over 100, that's when the problems begin)
Re: Help: creating contactsheet with imagemagic's montage
Posted: 2016-09-21T15:00:56-07:00
by snibgo
You are first reducing them down to 200x200 before reading them into montage, yes? So it doesn't matter how large the source images are?
Re: Help: creating contactsheet with imagemagic's montage
Posted: 2016-09-21T15:37:50-07:00
by t-boz
snibgo wrote:You are first reducing them down to 200x200 before reading them into montage, yes? So it doesn't matter how large the source images are?
no, not reducing them, if I do then the '%wx%h' label would give incorrect information about the image sizes. (if I add the
-define jpeg:size=200x200 option, as stated in the original post)
Re: Help: creating contactsheet with imagemagic's montage
Posted: 2016-09-21T16:10:09-07:00
by snibgo
Well, as they don't all fit into memory at once, I'm suggesting you first resize and label one at a time. Then montage these smaller images together.
The command that resizes and labels one image could be something like:
Code: Select all
convert $LOOPVAR -set option:mylabel "%wx%h\n%t" -resize 200 -gravity center label:"%[mylabel]" -append newdir/$LOOPVAR
Re: Help: creating contactsheet with imagemagic's montage
Posted: 2016-09-21T16:41:05-07:00
by t-boz
thanks, this solution works perfectly well, resizing them with proper labels for each ina loop and then just making a montage. Great,thanks!