Skip to content

Instantly share code, notes, and snippets.

@aozimkov
Created June 24, 2019 06:24
Show Gist options
  • Save aozimkov/8b3fc7b3cf7f4a6bc89ec2679637702d to your computer and use it in GitHub Desktop.
Save aozimkov/8b3fc7b3cf7f4a6bc89ec2679637702d to your computer and use it in GitHub Desktop.
Add text watermark with imagemagic (example)
#!/bin/bash
mkdir img-with-watermark
WATERMARK='Some text here'
for FILE in *.jpg; do
W=`identify -verbose "$FILE" | grep -oe "Geometry:.*" | sed -e 's/.*: //' | sed -e 's/x.*//'`
H=`identify -verbose "$FILE" | grep -oe "Geometry:.*" | sed -e 's/.*x//' | sed -e 's/+.*//'`
convert -background '#0000' -fill '#0004' -gravity center -size "$W"x"$(($H / 6))" caption:"$WATERMARK" ./"$FILE" +swap -gravity center -composite ./img-with-watermark/"$FILE"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment