#!/bin/sh
#
# add_watermark: add a visible watermark to photos
#
# meant to be used with my *-med.jpg images (480px high)
#
# Gerald Oskoboiny, 13 Aug 2008
#
# $Id: add_watermark,v 1.1 2008/11/10 14:01:41 gerald Exp $
#

# @@ should get this from image metadata
year=2008
# echo "current year is set to: $year; ok? (^C/^M)"
# read asdf

for f in "$@"; do
    w=`identify $f | awk '{print $3}' | sed 's/x.*//'`
    convert -comment \
       "Copyright $year Gerald Oskoboiny http://impressive.net/people/gerald/" \
      -quality 65 $f $f
    convert \
      -font courier -pointsize 14 -gravity SouthEast \
      -stroke black -draw "text 5,4 'impressive.net/photos'" \
      -stroke black -draw "text 7,4 'impressive.net/photos'" \
      -stroke black -draw "text 6,3 'impressive.net/photos'" \
      -stroke black -draw "text 6,5 'impressive.net/photos'" \
      -stroke '#ddd' -draw "text 6,4 'impressive.net/photos'" \
      $f $f
    name=""
    if [ $w -ge 380 ]; then # only include my name if the image is wide enough
      name=" Gerald Oskoboiny"
    fi
    convert \
      -font courier -pointsize 14 -gravity SouthWest \
      -stroke black -draw "text 5,4 '© $year$name'" \
      -stroke black -draw "text 7,4 '© $year$name'" \
      -stroke black -draw "text 6,3 '© $year$name'" \
      -stroke black -draw "text 6,5 '© $year$name'" \
      -stroke '#ddd' -draw "text 6,4 '© $year$name'" \
      $f $f
    exiftool -q -overwrite_original -Orientation=1 -n $f
done

