Page 1 of 1

Suggested batch code for image watermarking?

Posted: 2015-08-20T08:55:46-07:00
by user989797
I successfully used:

Code: Select all

composite -compose atop -geometry +75 -gravity southeast myhubbachat1.png pic.jpg photo-watermarked.jpg
to do what I want on one image.

I want a batch file to do it on 2k/x amount of images now.

So is that one still good with a little modfication or I need something more.

Please advise.

Im not tied to that code above its just the first one I happened across.

The watermark is the same for all images and I want it in same place- bottom right corner.

Oh and I also have .gif files as well as .jpg

Re: Suggested batch code for image watermarking?

Posted: 2015-08-20T09:10:37-07:00
by fmw42
You can use mogrify to watermark all images in a folder with another image located somewhere else. See http://www.imagemagick.org/Usage/basics/#mogrify and http://www.imagemagick.org/Usage/basics ... fy_compose.

I always create a new directory for the output and use the -path option.

So it would be something like

assume input directory is folder1 and has only images in it (such as gif and jpg and png, etc, no text files)
assume the watermark image is watermark.png (but it can be gif or jpg)
create a new empty directory of folder2
change directory to folder1

Code: Select all

mogrify -path path2/folder2 -format jpg -gravity southeast -draw 'image over 0,0 0,0 "watermark.png"' *

Re: Suggested batch code for image watermarking?

Posted: 2015-08-20T09:15:13-07:00
by user989797
thanks, but is that only for jpgs? do i have to make a second one for the gifs?

Im still very new to this :)

Oh i see what the format thing is for to make a new file rather than overwrite, but what if it was an animalted gif it would then be saved as a static jpg wouldnt it which i dont want.

Wouldnt it be easier to overwite original file in that case rather than write to new file cos then extention would stay the same?

Edit: I got it. Mixed your code with some from another thread I was reading. This did what I wanted:

Code: Select all

mogrify -gravity southeast -draw "image over 0,0 0,0 'watermark.png'" *

Re: Suggested batch code for image watermarking?

Posted: 2015-08-20T09:58:56-07:00
by fmw42
If you overwrite the image rather than create a new directory, you run the risk of destroying your original data by bad coding. The -format jpg was because I assumed you wanted jpg output from your example. I am not sure if mogrify will watermark very frame in an animated gif. I have not tested it. It might work. But you may have to use other techniques. See http://www.imagemagick.org/Usage/anim_m ... mpose_draw

Re: Suggested batch code for image watermarking?

Posted: 2015-08-20T11:51:22-07:00
by user989797
Well Im using copies so i dont see the problem?

The gifs took a while and were cpu intensive but seemed to work.