1

I have two sets of images in folder A and folder B. They share common file names. E.g. I have Image01 and Image02 in both the folders.

I need to superpose Image01 from folder A on Image 01 from folder B and so on respectively. Is there a way I can automate this using ImageMagick or batch processing?

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
Gokul N K
  • 2,428
  • 2
  • 32
  • 40
  • What do you mean by `superpose`? Is the top image smaller or transparent? What do you expect to see of the underlying image? – Mark Setchell Jan 11 '15 at 23:26

1 Answers1

3

Assuming your environment is Mac OSX or Linux or Unix...

Then you could this:

for img in A/* ; do        \
   convert                 \
      A/${img}             \
      B/$(basename ${img}) \
     -gravity center       \
     -compose blend        \
     -composite            \
     -alpha set            \
      composed.png         \
done

Now you have to understand: the description of your requirement is very, very unclear. Some questions remain:

  • Do the respective images of the same width/height dimensions?
  • Are they in the same file format? Do they use transparency/alpha channel?
  • How exactly do you want the superimposition to work?

There are a lot of different methods to superpose two images. To see the complete list, look at the output of this command:

convert -list compose

In my installation it shows 67 different methods:

Atop Blend Blur Bumpmap ChangeMask Clear ColorBurn ColorDodge Colorize CopyBlack CopyBlue CopyCyan CopyGreen Copy CopyMagenta CopyOpacity CopyRed CopyYellow Darken DarkenIntensity DivideDst DivideSrc Dst Difference Displace Dissolve Distort DstAtop DstIn DstOut DstOver Exclusion HardLight HardMix Hue In Lighten LightenIntensity LinearBurn LinearDodge LinearLight Luminize Mathematics MinusDst MinusSrc Modulate ModulusAdd ModulusSubtract Multiply None Out Overlay Over PegtopLight PinLight Plus Replace Saturate Screen SoftLight Src SrcAtop SrcIn SrcOut SrcOver VividLight Xor

My example command above uses only one of these, -compose blend.

You need to experiment with the different composition methods to see which one matches your idea. Here is a little illustration which shows you how some of the methods work when applied to two very simple shapes:

Before you start, you could look up and read a bit about the effects of the different methods:

Community
  • 1
  • 1
Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345