0

is it possible to add a different background image to a series of transparent pngs?

Like: convert sourceimage.png -background BackgroundPicture -flatten destinationimage.png

Of course the background image should be lowered to bottom of the frames.

Thanks in advance

  • Or another way would be puting a background image to the avi movie created by the series of pngs – user3012486 Jun 15 '17 at 10:07
  • Do you mean by `bash` instead of `batch`? –  Jun 15 '17 at 10:24
  • 1
    That's more of a usage (i.e. superuser) instead of programming (i.e. stackoverflow) question. – Michael Schumacher Jun 15 '17 at 10:27
  • @MichaelSchumacher I agree with you. By the way, I'm still wondering is this `convert.exe` or the Linux `convert`. Couldn't confirm it, yet. –  Jun 15 '17 at 11:06
  • Well, it wouldn't matter much - if you have ImageMagick installed on a MS Windows platform, then you have its convert.exe as well. Not really an issue, unless you are unexperienced and don't know which one will be used. – Michael Schumacher Jun 15 '17 at 12:33

2 Answers2

1

Actually convert is better than composite. Composite is old and less flexible. The convert syntax in ImageMagick for a foreground image with transparency and an opaque background image would be

convert backgroundimage.png foregroundimage.png -compose over -composite result.png

You can also apply the same foreground image to many background images, if you put all the background images in one folder (say test1). Keep the foreground image out of that folder, unless its suffix is different from all the files in the folder. Then create a new folder (say test2) to save the results. Then use mogrify with alpha composition to process all your files.

cd path2/test1
mogrify -format png -path path2/test2 -gravity center -draw "image over 0,0 0,0 'path2/foreground.png'" *.png

Where path2 is the actual path to the given folder or file.

see http://www.imagemagick.org/Usage/basics/#mogrify and http://www.imagemagick.org/Usage/basics/#mogrify_compose

You can go the other way to put different foreground images onto a given background image, if you put all the foreground images into the one folder (test1) and do the following:

mogrify -format png -gravity center -draw "image dst_over 0,0 0,0 'path2/background.png'" *.png
fmw42
  • 46,825
  • 10
  • 62
  • 80
0

ImageMagick's convert isn't the right tool. Use ImageMagick's coomposite instead. If all images are the same size, this is as simple as:

composite -compose atop Foreground.png Background.png Final.png
xenoid
  • 8,396
  • 3
  • 23
  • 49