Page 1 of 1

Append image to all images as background

Posted: 2014-08-06T14:49:16-07:00
by Rye
I have the following files (they all [obviously] have transparency)
089.GIF
090.GIF
091.GIF
092.GIF
093.GIF
094.GIF
095.GIF
096.GIF
097.GIF
098.GIF
099.GIF
100.GIF
101.GIF
102.GIF
102_2.GIF
103.GIF
105.GIF
106.GIF
and one file that shall be appended as background to each of them
background.gif

I want the output files to be png files.

How/Can this be done as batch with imagemagick ?


ALTERNATIVE:
Apply each image as foreground ? (but keep the filename... somehow ?)

Re: Append image to all images as background

Posted: 2014-08-06T15:45:59-07:00
by fmw42
First question is what platform are you running? Windows are some Unix variant?

You can either write a script to loop over each of your images and composite the image over the background. See
http://www.imagemagick.org/Usage/layers/#convert
You will need to script the loop and that will be platform depending.

The other way is to put all your images into one folder except for the background, which you need to keep elsewhere. Then create a new empty folder for the resulting composites. Then use mogrify to do -draw with composite to put the single background image under each of the images in your folder. see
http://www.imagemagick.org/Usage/basics/#mogrify
http://www.imagemagick.org/Usage/basics ... fy_compose
http://www.imagemagick.org/Usage/layers/#draw
http://www.imagemagick.org/Usage/compose/#duff-porter

Re: Append image to all images as background

Posted: 2014-08-06T17:17:20-07:00
by Rye
windows

the first suggestion sounds good.

Re: Append image to all images as background

Posted: 2014-08-06T18:12:06-07:00
by anthony
Look then at
Windows Batch Processing
http://www.imagemagick.org/Usage/windows/#for_loops

Re: Append image to all images as background

Posted: 2014-08-06T18:30:25-07:00
by Rye
Neat :)

Works like a charm:

Code: Select all

for %%x in (*gif) do convert background.png %%x -composite %%~nx.png


EDIT... thats what I thought at least...
for %%x in (*gif) do convert background.png %%x -composite %%~nx.png will now crash the cmd....
It worked like a charm before... ideas ?

Re: Append image to all images as background

Posted: 2014-08-08T05:12:06-07:00
by Rye
Ok, sorry that I reopened this.

But this script *should* technically work:

Code: Select all

@echo off
set app=background.png
timeout 1 > nul
for %%n in (*.gif) do convert -page +0+0  %app%   -page +0+0 %%n -flatten %%n
but doesn't.... it is STUCK on the first image... any idea ?