ImageMagick is an awesome image manipulation tool. It provides an command-line API for literally hundreds of functionalities related to image editing. Every now and then I need to apply watermarks to my images before posting them somewhere online, in public. GIMP, has one or two scripts which extend its functionalities but there’s no neat way to make them work nor use. So I decided to research a bit more about ImageMagick compose and create a very simple bash script to convert my images whenever I want.
To keep the alpha channel (transparency) of your watermarks you should use
.png images or
.svg. In my case,
.svg didn’t work as expected but I exported it as
.png. To breakdown the parts of the composite command see the section below; If you just want to get it done skip the next section.
To change the position of your watermark modify
-gravity with the available options
You can find more scripts in my github repo here
# Syntax: watermark-images.sh /path/to/dir /path/to/dir /path/to/logo.png extention
imgs=$(find "$sourcedir" -name *.$ext -print)
IFS=$(echo -en "\n\b")
if [ ! -d "$targetdir" ]; then
for i in $imgs; do
composite -compose atop -gravity southeast -background none "$watermark" "$i" "$targetdir/$(basename $i)"