Page 1 of 1
Batch Process Adding Watermark
Posted: 2018-04-26T10:12:44-07:00
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?
Re: Batch Process Adding Watermark
Posted: 2018-04-26T10:52:56-07:00
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
Re: Batch Process Adding Watermark
Posted: 2018-04-26T11:12:51-07:00
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.
Re: Batch Process Adding Watermark
Posted: 2018-04-26T12:22:16-07:00
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.
Re: Batch Process Adding Watermark
Posted: 2018-04-26T12:57:21-07:00
by jimtpowers
GeeMack, that did the trick. Thank you very much!
Re: Batch Process Adding Watermark
Posted: 2019-05-21T11:06:08-07:00
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)
Re: Batch Process Adding Watermark
Posted: 2019-05-21T11:13:21-07:00
by snibgo
Prefix the name with the directory (or drive and directory) in the normal way for your computer.