Montage with a fix size resulting image

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
novito
Posts: 30
Joined: 2013-11-26T17:37:36-07:00
Authentication code: 6789

Montage with a fix size resulting image

Post by novito »

Say I want to have a montage which size is 160x600. I have several images and I want to be able to put them there (resize if necessary) so that the resulting montage is 160x600.

Is there any way to specify the size of the montage? Or you can just specify the size of the tiles?

Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Montage with a fix size resulting image

Post by snibgo »

How about montaging them, and resizing at the end?
snibgo's IM pages: im.snibgo.com
novito
Posts: 30
Joined: 2013-11-26T17:37:36-07:00
Authentication code: 6789

Re: Montage with a fix size resulting image

Post by novito »

Let me clarify what I want and what I have:

I have:
- Set of N images with unknown width/height - I just know that width*height > 1200px

I need:
- A montage of 160x600 with the images of the above set on it (they can be repeated). So, if for example, the set of images height is small, the montage will have more rows.

I have thought on doing the following:

- Since we can set the size of the tile (for example, we can say that each tile is 40x100) we could do some maths and have:

Number of rows = 600/100 = 6 rows (we would need to take into account the margin between rows...)
Number of columns = 160/40 = 4 columns

However, if for example the images have a really short height, the rezing to 40x100 will mantain the aspect ratio, and therefore I would need more rows in order to fill up to 600px.

Any thoughts on how to do this?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Montage with a fix size resulting image

Post by fmw42 »

The -tile argument sets the number of tiles horizontally and vertically.

see http://www.imagemagick.org/Usage/montage/#settings
-tile {cols}x{rows}
The number of images across and down used to fill a single montage image. If more images were read in or created than fits in a single montage image, then multiple images will be created. (See Tile Controls above)
You can use the -geometry argument to resize the images (and spacing).

see linke above
-geometry {W}x{H}+{X}+{Y}
Resize images after they have all been read in before montage overlays them onto its canvas. It also defines the size and the spacing between the tiles into which the images are drawn. If no size is specified the images will not be resized.
But in the end, you may have to resize the output to get the size you want.
novito
Posts: 30
Joined: 2013-11-26T17:37:36-07:00
Authentication code: 6789

Re: Montage with a fix size resulting image

Post by novito »

Thanks :)
Post Reply