Bordering an image

Pictures look better when they have a border around them. To make things easy for me, I’ve written a small script that does a lot of boring things for me. It resizes an image so that it fits a 1000x1000 square, then creates a black border around it that’s a slight bit larger at the bottom and places my name and website URL on the side. Here is the code:

#!/bin/bash

[ -z "$1" ] && echo "Usage: $0 <file>" && exit 1

IN="$1"
IN_NOEXT=$(echo $IN | sed 's/\\.[^.]\\+$//')
OUT="$IN_NOEXT-bordered.jpg"
echo "INPUT: $IN"
echo "OUTPUT: $OUT"

BORDER_BOTTOM=40
BORDER_OTHER=20
POINTSIZE=12
COPYRIGHT="© 2007 Sybren Stüvel - https://www.stuvel.eu/"

DIFF=$((BORDER_BOTTOM - BORDER_OTHER))
EXIFTOOL=/usr/bin/exiftool

convert "$IN" \
 -geometry 1000x1000 \
 -mattecolor black \
 -frame ${BORDER_BOTTOM}x${BORDER_BOTTOM} \
 -chop ${DIFF}x${DIFF} \
 -gravity SouthEast \
 -chop ${DIFF}x0 \
 -font Bookman-Light \
 -font Helvetica-Narrow \
 -font Helvetica\
 -pointsize $POINTSIZE \
 -gravity SouthWest \
 -fill gray20 \
 -annotate 270x270+$((POINTSIZE+2))+${BORDER_BOTTOM} \
 "$COPYRIGHT" \
 "$OUT"

$EXIFTOOL -TagsFromFile "$IN" "$OUT"
rm -f "${OUT}_original"
dr. Sybren A. Stüvel
dr. Sybren A. Stüvel
Open Source software developer, photographer, drummer, and electronics tinkerer

Related