Append and Batch Process Images From Different Folders

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
sonicx
Posts: 1
Joined: 2015-07-14T13:20:27-07:00
Authentication code: 1151

Append and Batch Process Images From Different Folders

Post by sonicx »

I have several hundreds of images in one folder (Folder A) that need to be merged with 2 files in another folder (Folder B).

Folder A contains square 100x100 images. I've created a header and footer for the image that are in Folder B.

I need to merge the header and footer in Folder B with the square images in Folder A.

So the end result should be:
-- HEADER --
--IMAGE--
-- FOOTER --
I did a test for one image (see command below) where the header, image, and footer existed in the same folder, but how do I batch process it for hundreds of images?

Code: Select all

convert -append -quality 100 -gravity Center "C:\test\*.jpg" "C:\test\output\img.jpg"
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Append and Batch Process Images From Different Folders

Post by fmw42 »

Proper IM 6 syntax for convert should have the input image right after convert.

I believe that you will need to write a loop script to convert each image in folder A with the header and footer images using -append.

Alternately, append your header and footer images with a 100x100 size transparent image before hand, so you have just one image. Actually the transparent image could be any 100x100 sized image, since it will be covered over. Then use mogrify to processd all the images in folder A as foreground overlaying the one header/footer combined image. See mogrify

http://www.imagemagick.org/Usage/basics/#mogrify
http://www.imagemagick.org/Usage/basics ... fy_compose
http://www.imagemagick.org/Usage/compose/#duff-porter

use over for the compose method rather than dst_in.

Be sure to create a new empty folder to hold the output images so you do not make a mistake and write over your input images.

Example:

I put two gif image in folder test1 on my desktop (Mac OSX) and used rose.gif to overlay in the middle of each of the two images and save a png. I created a new folder test2 to hold the results.

Unix file paths. Change as needed for Windows

Code: Select all

cd /Users/fred/desktop/test1
mogrify -path /Users/fred/desktop/test2 -format png -gravity center \
-draw "image over 0,0 0,0 '/Users/fred/desktop/rose.gif'" *.gif

Please always provide your version of IM and platform when asking questions.
Post Reply