Page 1 of 1

Place image on a grid

Posted: 2015-10-10T06:46:24-07:00
by Hashirun
Hey guys,

is it possible in ImageMagick to place images in another image in specific grids? Please see the attached image, so the explanation makes more sense. So lets say I have 4 images and want to place each of them in one of the squares in the grid. I would want to fill each square with the given images.

Is that somehow possible? The version of ImageMagick does not matter. I would be using `Python`.

Image

Re: Place image on a grid

Posted: 2015-10-10T10:26:57-07:00
by fmw42
Yes it is possible. You have several choices in command line mode:

1) use montage (http://www.imagemagick.org/Usage/montage/)

2) use a combination of convert ... -resize -compose over -composite ... (http://www.imagemagick.org/Usage/layers/#convert)

See Python at http://www.imagemagick.org/script/api.php for choices of API

Re: Place image on a grid

Posted: 2015-10-10T11:54:09-07:00
by Hashirun
Great! Montage looks exactly what I was looking for. ImageMagick is so huge, sometimes its hard to fine the correct function. Thanks again, I'll look into montage!

Re: Place image on a grid

Posted: 2015-10-10T15:21:10-07:00
by glennrp
I generally use convert with the "draw image" option, which I find easier to understand. It's just

Code: Select all

-draw "image x,y w,h file.png"
where x and y are the location and w and h are the dimensions of the image being placed. You can have multiple instances of "-draw {options]" on the commandline.

Re: Place image on a grid

Posted: 2015-10-11T01:52:37-07:00
by Hashirun
Great, I might have to look into

Code: Select all

-draw [options]
since the montage option is not available for the Python APIs as far as I've seen.