Multiple watermarking in one command line with "composite" c

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
willie

Multiple watermarking in one command line with "composite" c

Post by willie »

Hi,

I got a directory which contains my watermarkimage and a couple of images which I want to watermark.

$ ls
img_5439-0.jpg img_5439-1.jpg img_5439-2.jpg img_5439-3.jpg img_5439-4.jpg img_5439-5.jpg img_5439-6.jpg img_5439-7.jpg watermark.gif

It works great when I am doing only one image at the time, see:

composite -dissolve 20% -gravity SouthEast -geometry -50+35 watermark.gif input.jpg output.jpg

But what I need is having input equal *.jpg

I tried:
composite -dissolve 20% -gravity SouthEast -geometry -50+35 watermark.gif *.jpg
composite -dissolve 20% -gravity SouthEast -geometry -50+35 watermark.gif *.jpg *.jpg
composite -dissolve 20% -gravity SouthEast -geometry -50+35 watermark.gif *

but it ain't work.

Do I actually need to write a shell script for the loop or is there an easy way for my problem ?

Thanks.

Regards
brian_jackson

Re: Multiple watermarking in one command line with "composite" c

Post by brian_jackson »

Yes, you're going to want to write a little for loop to do this. The syntax you're trying to use looks rather DOSish :)

for i in *jpg; do
composite -dissolve 20% -gravity SouthEast -geometry -50+35 watermark.gif $i out_$i
done

you can change whatever you want the output to be, I just happened to prepend 'out_' to the beginning of the filename, to preserve the original file, you can do all sorts of things.

for example, if you want to change 'img' to 'wm' do this:
wm${i#img} as your outfile will rename img_5439-0.jpg wm_5439-0.jpg

Oh, all this assuming your're running bash.

good luck,
brian
willie

Re: Multiple watermarking in one command line with "composite" c

Post by willie »

Many Thanks !

Regards
Post Reply