I have a batch of roughly 2000 png image files with alpha layer.
I want to add a background image to those 2000 files.
I'm a newbie at this so I'm not sure what type of method I should use to combine this.
I have the background file in a separate folder from the batch.
All that needs to be done is to combine the background image with each of the batch files, so other modification is needed.
Is there a simple way to just combine all images in folder x with image y.png?
I've looked around in the documentation and this forum, and I'm not really sure what's best for my case.
Simplest to add a background image to a batch of images
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Simplest to add a background image to a batch of images
What version of IM, on what platform?
The first step is to find the IM command that does what you want to a single input image. Perhaps:
When you know what command you need, the simplest way to apply that to all the images is to put that command in a shell loop. However, if the inputs are small you might do it in a single IM command, and this may be faster because the background image needs to be read just once.
The first step is to find the IM command that does what you want to a single input image. Perhaps:
Code: Select all
magick in.png backgnd.png -composite out.png
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Simplest to add a background image to a batch of images
You can use mogrify to process all images in a directory with one common image in a composite operation. See
https://imagemagick.org/Usage/basics/#mogrify
https://imagemagick.org/Usage/basics/#mogrify_compose
First create a new directory to hold all your images.
If using IM 7, the add magick before mogrify.
https://imagemagick.org/Usage/basics/#mogrify
https://imagemagick.org/Usage/basics/#mogrify_compose
First create a new directory to hold all your images.
Code: Select all
mogrify -path path/to/newdirectory -format png -draw 'image Dst_Over 0,0 0,0 "background.png"' *.png