I found a web blog from
Frederico Maggi who posted a nice tutorial for batch editing image files to add a border with some Exif data.
The work by Frederico was a great start and I took his work and made a few treaks. The major change I made was to the
~/bin/lr_borderscript. I felt that the border size was too small and that the text was too small. I also adapted the script to perform a rename using the convert utility
#!/bin/sh
#File: ~/bin/lr_border
year=$($HOME/bin/exiv_year $1)
data=$($HOME/bin/exiv_data $1)
name="Carl Wainwright © "
if [ -n "$year" ]
then
name=$name" "$year
fi
inname=`convert $1 -format "%t" info:`
echo "Processing $inname"
outname=${inname}_mod.jpg
#convert $1 -resize 50% $outname
convert $1 $outname
echo "Writing to $outname"
mogrify -gravity North -border 5x5 -bordercolor black $outname
mogrify -gravity North -border 1x1 -bordercolor grey $outname
mogrify -gravity North -border 60x60 -bordercolor black $outname
if [ -n "$data" ]
then
mogrify -pointsize 30 -fill white -gravity SouthEast -annotate +25+6 "$name" -gravity SouthWest -annotate +25+6 "$data" $outname
else
mogrify -pointsize 30 -fill white -gravity SouthEast -annotate +25+6 "$name" $outname
fi
I also modified the exiv_data script to match the Exif data for my Konica Minolta 7D.
#!/bin/sh
#File: $HOME/bin/exiv_data
time=$(exiv2 -PEkt pr $1 2>/dev/null | tr -s " " " " | grep -E "\.Photo\.ExposureTime" | awk '{print $2}')
focal=$(exiv2 -PEkt pr $1 2>/dev/null | tr -s " " " " | grep -E "\.FocalLength " | awk '{print $2}')
aperture=$(exiv2 -PEkt pr $1 2>/dev/null | tr -s " " " " | grep -E "\.Photo\.FNumber" | awk '{print $2}')
iso=$(exiv2 -PEkt pr $1 2>/dev/null | tr -s " " " " | grep -E "\.ISOSpeedRatings" | awk '{print $2}')
if [ -n "$time" -a -n "$focal" -a -n "$aperture" -a -n "$iso" ]
then
echo $focal"mm, "$time" @ "$aperture" (ISO "$iso")"
fi
Executing the above script can be done as follows
ls *.JPG | while read file; do ~/bin/lr_borderscript_new $file; done