Batch/Automating Combining 2 Images Into 1

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
c_g
Posts: 1
Joined: 2012-12-11T17:09:47-07:00
Authentication code: 6789

Batch/Automating Combining 2 Images Into 1

Post by c_g »

I'd like to automate the task of combining 2 images into 1, but have almost no knowledge of how to accomplish this in batches.

I have a folder with 100 logo images - all transparent PNGs. They're not exactly the same size, but similar.

I also have a single PNG slogan that I'd like to appear under each of these logos.

The final product would be a transparent PNG with the PNG logo, centered above the PNG slogan. The final product(s) would all need to be the same size, regardless of the logos relative size to the slogan or anything else.

I've created a bit of a walkthrough visually, since I fear my ability to explain myself is hindered by my inability to create my own solution.

Walkthrough/general idea:http://i.imgur.com/FJuf1.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch/Automating Combining 2 Images Into 1

Post by fmw42 »

You can append the images vertically. If needed you can either add a spacer all white image or use -border, -extent or -slice to add a white buffer or some combination of them.

see
http://www.imagemagick.org/Usage/crop/#border
http://www.imagemagick.org/Usage/crop/#extent
http://www.imagemagick.org/Usage/crop/#splice
http://www.imagemagick.org/Usage/layers/#append

Or alternately, create a white background image the desired size and compose the two images onto it using -gravity and -geometry. This may be the most direct method.

see
http://www.imagemagick.org/Usage/layers/#convert


You can batch process by using mogrify. See http://www.imagemagick.org/Usage/basics/#mogrify

First mogrify all the images to to extend them to the right size white background and possibly add a white border. Then do another mogrify to composite the same text image onto each one.
Post Reply