Skip to content

Instantly share code, notes, and snippets.

@venam
Last active November 26, 2015 06:23
Show Gist options
  • Save venam/6ceb31bd6f06fe79a221 to your computer and use it in GitHub Desktop.
Save venam/6ceb31bd6f06fe79a221 to your computer and use it in GitHub Desktop.
watermark a bunch of image files in a dir
#!/bin/bash
if [ "$#" -lt 2 ]; then
echo "Usage: $0 dir text" >&2
exit 1
fi
# 1275x1650 - the size of the A4 images
dir=$1
text=$2
#create the directory for the watermarked images
if [ -d "$text/$dir" ]; then
echo "directory $text/$dir already exists"
exit
fi
mkdir -p "$text/$dir"
#create the watermak image
convert -rotate 75 -background "none" -pointsize "180" -stroke "#00000099" -strokewidth "1" -fill "#FFFFFF09" -font 'arialbd.ttf' "label:$text" "$text/watermark.png"
for page in $dir/page-*.jpg; do
b="$(basename $page)"
echo $b
composite -geometry "+0-10" -gravity "center" "$text/watermark.png" "$page" "$text/$dir/$b"
echo $page
done
echo "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment