Batch Montage onto 6x4 photo size

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
SigilPhoenix
Posts: 4
Joined: 2011-05-02T22:17:06-07:00
Authentication code: 8675308

Batch Montage onto 6x4 photo size

Post by SigilPhoenix »

Hi all, first time here.

Version: ImageMagick 6.4.0 Q16, on a full Cygwin install on Win7.

I have approx 245 jpg images that are all the same size (roughly passport portrait, they're a little bit taller because I added photo names at the bottom).
What I would like to do is put every 4 images together in a grid on a 6"x4" canvas so that I can print them off later (I have 6x4 photo paper).

I had a look at the montage examples, but I couldn't quite figure out how to achieve this.

Thanks in advance.

EDIT: Oh, I definitely don't have an exact multiple of 4, what I will do is remove however many I need to from the end to make it 4 and do the remaining <4 myself manually, unless the script can easily handle that?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch Montage onto 6x4 photo size

Post by fmw42 »

Sorry I am not clear on what you want to do. Is it just put 4 photos together in a 2x2 array in one photo and do it for all the your photos so that you have multiple montages of 2x2 images? Is your issue with making one montage or with trying to do all the photos at one time? The latter would require a script. Using montage on 4 photos is not very hard.

montage image1 image2 image3 image4 -tile 2x2 -geometry +X+Y -background white resultimage

This will put these 4 images into one picture as a 2x2 array with white spacing of X and Y between them.

see http://www.imagemagick.org/Usage/montage/
SigilPhoenix
Posts: 4
Joined: 2011-05-02T22:17:06-07:00
Authentication code: 8675308

Re: Batch Montage onto 6x4 photo size

Post by SigilPhoenix »

Thanks for the reply.

My problems are writing the script, as you say it requires. Just one I can do, but scripting it I can't figure out.

My other issue is I want the 2x2 montage to roughly the size of a 6"x4" photo - can this be done, or do I just have to make sure the images are the right size to begin with and this will be dealt with automatically?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch Montage onto 6x4 photo size

Post by fmw42 »

My other issue is I want the 2x2 montage to roughly the size of a 6"x4" photo - can this be done, or do I just have to make sure the images are the right size to begin with and this will be dealt with automatically?
You will need to figure out how big (WidthxHeight) your resulting 2x2 montage will be and then set the -density and -units appropriate for the output format (jpg or png, etc) to achieve a printable 6x4" size. You will need to set this after the montage as I don't see those as settings for the montage command at http://www.imagemagick.org/Usage/montage/#settings

For example

montage in1 in2 in3 in4 ... miff:- | convert - -density XXxYY -units pixelsperinch resultimage.

Or create a temp file from montage and feed that to convert in a separate command.

see http://www.imagemagick.org/script/comma ... hp#density and http://www.imagemagick.org/script/comma ... .php#units (The default units are pixelsperinch, but note that png requires pixelspercentimeter, though if set properly IM can convert it for you)
SigilPhoenix
Posts: 4
Joined: 2011-05-02T22:17:06-07:00
Authentication code: 8675308

Re: Batch Montage onto 6x4 photo size

Post by SigilPhoenix »

Cheers!

Regarding automatically scripting it though to go through all the images (assume multiple of 4 images), I'm still scratching my head, any pointers?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch Montage onto 6x4 photo size

Post by fmw42 »

SigilPhoenix wrote:Cheers!

Regarding automatically scripting it though to go through all the images (assume multiple of 4 images), I'm still scratching my head, any pointers?
Put all your filenames into an array. Then loop over the array with a skip of 4. Something like this, though not tested.

cd "$imagedir"
imgArr=(`ls "$imagedir"`)
imgcount=${#imgArr[*]}

k=0
for ((i=0;i<$imgcount;i=$i+4)); do
montage ${imgArr[$i]} ${imgArr[$i+1]} ${imgArr[$i+2]} ${imgArr[$i+3]} ... resultimage_$k.jpg
k=$(($k+1))
done
SigilPhoenix
Posts: 4
Joined: 2011-05-02T22:17:06-07:00
Authentication code: 8675308

Re: Batch Montage onto 6x4 photo size

Post by SigilPhoenix »

Thank you, much appreciated - I can work with that.
PhoneFlea
Posts: 1
Joined: 2011-07-21T13:30:21-07:00
Authentication code: 8675308

Re: Batch Montage onto 6x4 photo size

Post by PhoneFlea »

First and foremost, I'd like to acknowledge that I'm aware of the age of this post. I just wanted to come on here to quickly thank all of your for your help. I'm attempting to create a collage of photos (much like SigilPhoenix here) in order to print them off. The issue is that I'm not very tech savvy and I'm very new to ImageMagick. With any luck, these suggestions and instructions will be super helpful. I'll let you all know when I'm done printing these photos off. That is. . .if I DO get them printed off. Take care, everybody! ;)
Marissa
Are brother mfc 7420 printers easy to find?
Post Reply