Combining section of multiple images into a new 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
issle
Posts: 1
Joined: 2012-07-02T02:43:41-07:00
Authentication code: 13

Combining section of multiple images into a new image.

Post by issle »

I have a set of images ( lets call them source1.jpg source2.jpg source3.jpg etc ... ) and i want to crop a square area out of each image ( defined by x,y,width,height foreach image ) and then draw it on a shared canvas image at a specific point ( x,y ).

I can use convert -crop for each source image to get the section of the image i want into a seperate file and then composite -geometry to place it on the shared canvas image.

What i would like to know is if it is possible to do all this operation with one single command without having to generate intermediate files so as not to have IO overhead and so as not to have to execute multiple commands. I would much appreciate an example if possible.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Combining section of multiple images into a new image.

Post by fmw42 »

You can cut and composite each image with the canvas in sequence in one command line. see http://www.imagemagick.org/Usage/layers/#convert

Put each image and the crop command in parenthesis. Be sure to add +repage after the crop.

see
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/crop/#crop_repage
Post Reply