Montage question

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
Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Montage question

Post by Don »

Hello,

I was wondering if it is possible to replicate the image below with imagemagick using the montage command?

https://picasaweb.google.com/lh/photo/I ... directlink

I have tried but I get a lot of white space in my example below. If I can reduce most of the white space, that would be great at least.

This is the command for the image below:
montage batmanboy.jpg 400lomoupmi.png 700wbmwm3race.png 0001.jpg dkr-poster.jpg IMG_8687.jpg -tile 2x -geometry 400x400\>+2+2 montage.png

https://picasaweb.google.com/lh/photo/s ... directlink

Thank you.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Montage question

Post by fmw42 »

It is hard to know without having your individual input images. If the following does not work, then upload them to dropbox.com (public folder) and put links here.

You may not be able to get them closer unless the images are all the same size. The tile size will be the same for all images as the largest image. Any smaller images will be padded with background. You might consider cropping them all after resizing to the same dimensions.

Code: Select all

convert batmanboy.jpg 400lomoupmi.png 700wbmwm3race.png 0001.jpg dkr-poster.jpg IMG_8687.jpg \
-resize "400x400>^" -gravity center -crop 400x400+0+0 +repage miff:- |\
montage - -tile 2x -geometry +2+2 montage.png
The above is unix syntax. Windows differs. So when you post, please always identify your version of IM and platform.

Note the use of ^ as well as >. The ^ indicates to resize so that the smaller dimension of the image becomes 400.

In window, I believe you would need ^^ and replace \ at the end of lines with ^.

see http://www.imagemagick.org/Usage/windows/

The other way to do this is to use append

Code: Select all

convert \( batmanboy.jpg 400lomoupmi.png -gravity south +append \) \
\( 700wbmwm3race.png 0001.jpg -gravity center +append \) \
\(  dkr-poster.jpg IMG_8687.jpg -gravity north +append \) \
-gravity center -append append.png
change the gravity settings as desired
Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Re: Montage question

Post by Don »

Thank you for your assistance.

That seems to work perfectly but now was also wondering... is it possible to somehow to have images that are big in width (basically 'landscape' images) to take up a whole row in the montage while the 'portrait' sized images for the montage are lined up next to each other underneath the landscape image? To get an idea of what I mean, see the first image in my first post.

Thank you!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Montage question

Post by fmw42 »

I do not think Montage will do that automatically. You could do that using append and writing some script to decide if the image is wide enough to fit one row.
Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Re: Montage question

Post by Don »

Hmm yes I figured automatically it would not be able to do that.

Lets say if I figured out from the image names below in the following convert command that the image labeled: resized0001.jpg has a total width of 711 and the two more additional images that are resized to be about 355 in width to fit below the 711 image next to eachother. I would like to have the 711 width image to be ontop of the 355 width images.

Here is an example of what I mean above: https://picasaweb.google.com/lh/photo/I ... directlink

Here is the convert command I tried: convert resized0001.jpg -append miff:- | convert 355img8687.jpg 355lomoupmi.png +append done.png

Thank you.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Montage question

Post by fmw42 »

try this

Code: Select all

convert resized0001.jpg \( 355img8687.jpg 355lomoupmi.png +append \) -append result
You can add -gravity as desired.

see
http://www.imagemagick.org/Usage/layers/#append
http://www.imagemagick.org/Usage/basics/#parenthesis
Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Re: Montage question

Post by Don »

Thanks that worked perfectly!

Quick resize question... Say I had an image that is 1500 width by 1950 height.. with the following convert command... how is the image resized:

convert myimage.png -resize 1000x1000> resized.png

I know that the command above means: 'resize the image if larger than the specified values' but how exactly does it get resized? By width first or by height? Since both height and width are larger than the specified values(1000), how does this command go about resizing the image? I am assuming it will resize by the width first and only by the width since it's the first in the command and then the height will automatically be determined from that.

Thank you!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Montage question

Post by fmw42 »

The largest dimension of the image will become 1000 and the smaller will be less than 1000 in proportion to the image's aspect ratio. If you want the smaller dimension to become 1000, then use ^> rather than just >. See

http://www.imagemagick.org/script/comma ... p#geometry
Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Re: Montage question

Post by Don »

Hey guys, I thought I would post here in this thread again since it basically deals with image resizing because of the previous posts...

I am currently trying to do a simple resize. The image I have is 1600 by 1200. I run this command: convert IMG_8687.jpg -resize 1000x400\> resized.png, the image resizes too: 533 by 400. Isn't it suppose to resize by 1000 since 1600(the width) is the larger dimension?

Thanks in advance.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Montage question

Post by fmw42 »

Don wrote:Hey guys, I thought I would post here in this thread again since it basically deals with image resizing because of the previous posts...

I am currently trying to do a simple resize. The image I have is 1600 by 1200. I run this command: convert IMG_8687.jpg -resize 1000x400\> resized.png, the image resizes too: 533 by 400. Isn't it suppose to resize by 1000 since 1600(the width) is the larger dimension?

Thanks in advance.
You should really have posted this to a new topic, since it has nothing to do with montage. In general, unless you are replying specifically to the question of the topic, it is best to make a new post.

Anyway,

resize with > means only resize if one of your image dimension is larger than the dimension specified by the -resize arguments and it uses the largest ratio, I think, to decide how much to resize. So 1200/400=3 and and 1600/1000=1.6. So it will resize to 400 height and you get whatever width maintains the aspect ratio, in this case 1600/3=533.

If you want it to resize to the smaller ratio, use

convert IMG_8687.jpg -resize 1000x400\^\> resized.png

which gives a resulting size of 1000x750.

see
http://www.imagemagick.org/script/comma ... p#geometry
Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Re: Montage question

Post by Don »

Apologies, will make a new thread next time. :)

Thanks.
Post Reply