Skip to content

Instantly share code, notes, and snippets.

@2xlink
Last active April 24, 2019 12:17
Show Gist options
  • Save 2xlink/80576f9e5d28f54069ae73a2670588e1 to your computer and use it in GitHub Desktop.
Save 2xlink/80576f9e5d28f54069ae73a2670588e1 to your computer and use it in GitHub Desktop.
Watermarks photos of your personal documents using ImageMagick
#!/bin/bash
set -euo pipefail
if [[ $# -ne 2 ]]; then
echo "Usage: $0 IMAGE WATERMARK-TEXT"
exit 1
fi
FILE=$1
TEXT=$2
TARGET_FILE=${FILE%.*}-watermark.${FILE##*.}
convert -size 2000x1000 xc:none -fill "#00000070" \
-gravity NorthWest -pointsize 300 -draw "text 75,80 '$TEXT'" \
-gravity SouthEast -pointsize 300 -draw "text 50,160 '$TEXT'" \
miff:- |\
composite -tile - $FILE $TARGET_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment