Noted in another thread about watermarking using digikam, and thought Id share how I go about it using imagemagick and a script to do a batch of images in a folder.
My reasoning is I dont use digikam, and cant be bothered going through darktable history and removing the watermark if someone wished to purchase a print/file.
Workflow is:
- export from darktable/whatever to the
/source
sub-directory - run the script, it will take every image from the
/source
folder, resize and add watermark, and export to a/watermarked
subdirectory - check the images in the
/watermarked
directory are as I want, upload/whatever.
It’s nice once set up, and is pretty speedy.
Here’s the script for 1920 on whichever long edge:
#!/bin/bash
for i in ./source/*.jpg ./source/*.jpeg ./source/*.png
do
if [ ! -d "./watermarked" ]; then mkdir "./watermarked"; fi
filename=$(basename "$i")
/bin/convert \
-filter Lanczos \
"$i" \
-set option:filter:filter Lanczos \
-set option:filter:blur 0.8 \
-resize 1920x1920 \
-quality 90 \
./Logo/SIF_Logo_300.png -gravity SouthEast -geometry +20+15 -compose Multiply -composite \
"./watermarked/$filename"
done
if you want a windows batch file:
@echo off
FOR %%i IN (./\*.jpg ./\*.jpeg ./\*.png) DO (
IF NOT EXIST ./\watermarked mkdir watermarked
convert ^
-filter Lanczos ^
"%%i" ^
-set option:filter:filter Lanczos ^
-set option:filter:blur 0.8 ^
-resize 1920x1920 ^
-quality 90 ^
./Logo/SIF_Logo_300.png -gravity SouthEast -geometry +20+15 -composite ^
"./\watermarked\%%~nxi"
)
Bit of a breakdown of what its doing, and so you can modify to suit you:
Top part sets up the folders, created the output folder if it’s not there.
Next lines are the filtering for the resize, and the dimensions for the long edge; adjust as you see fit.
And output jpg quality.
source for the watermark image, I have watermarks in a subfolder /Logo
- the preceding dot tells it that it’s a sub-folder from the script folder.
-gravity North/South/etc
sets starting point of Logo position
-geometry Lat/Long
offset from starting position. Change the values and you’ll work it out.
-compose Multiply
adds the image using “multiply” like a photoshop filter; whites fade into he background. I just like how it looks sometimes, it’s not essential.
-composite
combines the original image and the watermark
Output directory/name.
Obviously you will need imagemagick installed from your repo. Or the website if you’re on Windows.
Credit: How to automatically watermark or batch watermark photos using ImageMagick | xoogu