Batch Process Adding Watermark

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
jimtpowers
Posts: 3
Joined: 2018-04-26T10:01:57-07:00
Authentication code: 1152

Batch Process Adding Watermark

Post by jimtpowers »

Hello,

I am running on Windows 10 and ultimately on a 2008R2 server for automation. The version I downloaded and installed is 7.0.7-28-Q16-x64.

I will have 30-50 images per week that will need a watermark added to the lower right corner. All images are a 640x480 .JPG. Final output must be 640x480 for our software to work with the image. The watermark is a scalable .PNG at 1200x1200.

Photos will be placed in a network directory location that will be accessible to a Windows Task scheduler item.

I need to have ImageMagick take each source photo, add the watermark to the lower right corner and then OVERWRITE the original with the same file name.

Is this possible and if so, how?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch Process Adding Watermark

Post by fmw42 »

You can use mogrify to process a whole folder of images with the same watermark image. I do not know of any "scalable" raster formats such as PNG. What do you mean by scalable. Imagemagick can resize that image, but it will be resampled. It is not like having a vector image such as PDF or EPS or AI that scales with density. Please post an example image or two and your watermark and we can test for you. Or see mogrify at https://www.imagemagick.org/Usage/basics/#mogrify and especially https://www.imagemagick.org/Usage/basic ... fy_compose
jimtpowers
Posts: 3
Joined: 2018-04-26T10:01:57-07:00
Authentication code: 1152

Re: Batch Process Adding Watermark

Post by jimtpowers »

My apologies for not getting the terminology correct. I would be happy to attach the watermark we want added to the photos but cannot find how to do it.

I looked over the link you sent me and it appears the mogrify command, based on the basic description will meet the "overwrite" requirement. However, I can't find (or I'm getting lost in my mind) the command to join the images together, resizing the watermark to a smaller, more appropriate size.

Your help is greatly appreciated.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Batch Process Adding Watermark

Post by GeeMack »

jimtpowers wrote: 2018-04-26T11:12:51-07:00I looked over the link you sent me and it appears the mogrify command, based on the basic description will meet the "overwrite" requirement. However, I can't find (or I'm getting lost in my mind) the command to join the images together, resizing the watermark to a smaller, more appropriate size.
Instead of "mogrify" I'd probably approach this using "magick", which will also happily overwrite the original image, and it makes resizing your logo pretty easy. I'd run it in a Windows BAT script using a "for" loop to process all the input images. A script like this shows how it can be done...

Code: Select all

@echo off
for %%z in ( *.jpg ) do (
   magick "%%z" logo.png ^
      -resize %%[fx:t?u.w*0.1:s.w]x%%[fx:t?u.h*0.1:s.h] ^
      -gravity southeast -geometry +30+30 -composite "%%z"
)
That uses Windows "for" to process each *.jpg file one after the other. For each run of the loop, IM reads in one input image and the logo overlay, resizes the logo to 10% the size of the input image, sets the gravity and geometry to place the logo 30 pixels up and over from the bottom right corner, applies the logo to the input image, and writes the output with the same name as the input.

If your input images and your logo have the same extension, like if they're all .png files, you'll probably need to put your logo or your inputs, or both, in separate folders and read them in using the path(s) to those folders.
jimtpowers
Posts: 3
Joined: 2018-04-26T10:01:57-07:00
Authentication code: 1152

Re: Batch Process Adding Watermark

Post by jimtpowers »

GeeMack, that did the trick. Thank you very much!
onsiteeng
Posts: 1
Joined: 2019-05-21T10:50:18-07:00
Authentication code: 1152

Re: Batch Process Adding Watermark

Post by onsiteeng »

Sorry to necro thread this, but this is the exact thing I was looking for. Can the logo file be located anywhere on the computer/server and pointed to, to add it as a watermark to an image? Or does it need to be located in the root folder where the images that need to be watermarked are located?

(newbie to imagemagick here)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Batch Process Adding Watermark

Post by snibgo »

Prefix the name with the directory (or drive and directory) in the normal way for your computer.
snibgo's IM pages: im.snibgo.com
Post Reply