I played around with imagemagick cause I wanted to add a frame to all my flickr picyures.
The frame I wanted is a blur effect aroud my picture and a signature on the lower right-west area.
So here is my script which does the job, but as I'm new to imagemagick I was wondering if it can
be improved ?
Code: Select all
#!/usr/bin/env bash
# user variables
BORDER_COLOR=white
TEXT_COLOR=white
MAX_WIDTH=1600
BORDER_WIDTH=2
# auto compute value
SIZE_PX=$(($MAX_WIDTH/80))
TEXT_SIZE=$((MAX_WIDTH/50))
TEXT_OFF=$((TEXT_SIZE/5))
file=$1
outfile=$2
if [ ! -r $file ]; then
echo "cannot read $file"
fi
echo -n "+ creating frame for $file"
convert $file -resize ${MAX_WIDTH}x${MAX_WIDTH} -auto-orient $outfile
WIDTH=$(identify -format "%w" $outfile)
HEIGHT=$(identify -format "%h" $outfile)
convert $outfile -resize $(($WIDTH+2*($SIZE_PX+$BORDER_WIDTH)))x$(($HEIGHT+2*($SIZE_PX+$BORDER_WIDTH)))! -blur 0x18 \( $outfile -bordercolor $BORDER_COLOR -border ${BORDER_WIDTH}x${BORDER_WIDTH} \) -gravity center -composite -strokewidth 1 -stroke none -fill $TEXT_COLOR -gravity southwest -pointsize $TEXT_SIZE -font "/home/nach/.fonts/Century.ttf" -annotate +$(($SIZE_PX+$BORDER_WIDTH+$TEXT_OFF))+$(($SIZE_PX+$BORDER_WIDTH)) "www.test.biz/photos" $outfile
echo "...done"
Fred