Place image on a grid

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
Hashirun
Posts: 3
Joined: 2015-10-10T06:08:40-07:00
Authentication code: 1151

Place image on a grid

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Place image on a grid

Post 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
Hashirun
Posts: 3
Joined: 2015-10-10T06:08:40-07:00
Authentication code: 1151

Re: Place image on a grid

Post 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!
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Place image on a grid

Post 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.
Hashirun
Posts: 3
Joined: 2015-10-10T06:08:40-07:00
Authentication code: 1151

Re: Place image on a grid

Post 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.
Post Reply