#!/bin/sh
#
# see a saple framed picture here: https://dl.dropbox.com/u/85604141/Pic/DSC_3491_BD.jpg
#
# 1- download the scripts here: https://dl.dropbox.com/u/85604141/Pic/genPicBorder.sh
# 2- make it excutable: $ chmod u+x genPicBorder.sh
# 3- how to use it: $ ./genPicBorder.sh
#
#######
#
# define fonts; check your system to see what is available using
# this comand line: $ convert -list font
exiffont="Courier"
textfont="Papyrus-Regular"
timefont="Copperplate-Light"
signfont="Bauhaus-93-Regular"
# define font colors
exifcolor="gray80"
textcolor="blue"
timecolor="gray70"
signcolor="gray70"
mysign="qp"
########
if [ $# -lt 2 ]
then
cat << _EOF_
--------------------------------˚
USAGE: ./genPicBorder "text description of the picture" file1 file2 ..., or
./genPicBorder "text description of the picture" *.jpg, or
./genPicBorder "text description of the picture" directory/*.jpg
...
--------------------------------˚
_EOF_
exit
fi
text="$1"
while [ "$2" != "" ]; do
# Skip directories
if [ -d "$2" ]; then
shift
continue
fi
# Skip already converted files (may get overwritten)
if [[ $2 == *_BD* ]]
then
echo "------ Skipping: $2"
shift
continue
fi
# adding "_BD" before file extension
file=$2
echo "====> Working on file: $file"
filename=${file%.*}
extension=${file##*.}
output=${filename}_BD.${extension}
# Get the file dimension
dim=$(identify -format "%w %h" "$file")
width=${dim%% *}
height=${dim#* }
blk=$(($height/20))
# Decide the font size automatically
if [ $width -ge $height ]
then
pointsize=$(($width/50))
else
pointsize=$(($height/50))
fi
pointsize2=$(($height/10))
dd=$(identify -format "%[EXIF:DateTimeOriginal]" "$file")
# date
dd1=${dd%% *}
# time hh:mm:ss
dd2=${dd#* }
# time hh:mm
dd3=${dd2%:*}
echo " Width: $width, Height: $height. Using pointsize: $pointsize and $pointsize2 with blank $blk"
################################################################
convert "$file" \
-gravity southeast -font $exiffont -pointsize $(($pointsize*3/4)) -fill $exifcolor -annotate +0+0 "%[EXIF:Model] ($width\x$height) %t" \
-bordercolor white -border 10 \
-gravity south -font $textfont -pointsize $pointsize -fill $textcolor -splice 0x$blk -annotate +0+$(($blk/2-$pointsize*3/4)) " $text" \
-gravity southeast -font $timefont -fill $timecolor -annotate -10+$(($blk/2-$pointsize/2)) " $dd1 @ $dd3 " \
-gravity southwest -font $signfont -pointsize $pointsize2 -fill $signcolor -annotate +100-3 "$mysign" \
-bordercolor gray40 -border 3 -bordercolor gray10 -border 1 \
-mattecolor gray99 -frame 1%x1%+3+3 \
"$output"
################################################################
# 1- add exif info at the right-bottom corner
# 2- add a white border immediately outside of the picture; -bordercolor white -border 10
# 3- add $text (extra white space defined by $blk)
# 4- add date/time info
# 5- add $mysign
# 4- add a gray border; add a black border;
# 5- add a frame
#
shift
done
exit 0
本贴由[大清太平]最后编辑于:2012-8-26 14:50:6 --- |