Burn exif meta data to photos

Burn exif meta data to photos

People always ask me "what were your camera settings for that photo", so I wrote some bash functions to burn the relevant data to the bottom of the image.

The following bash functions assume a few things:

Once you have met the requirements, you just need to put the following functions in your appropriate profile.

function exifshort(){

  if hash exiftool 2>/dev/null; then
    echo ""
  else
    if [ "$(uname)" == "Darwin" ]; then
      brew install exiftool
    elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
      sudo apt install exiftool
    fi
  fi

  FILE=$1
  if [ -z "$FILE" ];then
    echo "${red}You must specify a file path${default}"
    exit 1
  else
    MODEL=`exiftool -Model $FILE | awk -F ': ' '{print $2}'`
    ISO=`exiftool -ISO $FILE | awk -F ': ' '{print $2}'`
    LENS=`exiftool -LensModel $FILE | awk -F ': ' '{print $2}'`
    EXPOSURE=`exiftool -ExposureTime $FILE | awk -F ': ' '{print $2}'`
    DATE=`exiftool -CreateDate $FILE | awk -F ': ' '{print $2}'`
    APERTURE=`exiftool -ApertureValue $FILE | awk -F ': ' '{print $2}'`
    FOCAL_LENGTH=`exiftool -FocalLength $FILE | awk -F ': ' '{print $2}'`

    echo "$MODEL + $LENS @ $FOCAL_LENGTH, ISO $ISO, $EXPOSURE seconds, f/$APERTURE, $DATE"
  fi
}
function burnexif(){
  IN=$1
  PAD=100
  FONT_SIZE=32

  PATH_IN=$(readlink -f $IN)
  EXTENSION=${PATH_IN##*.}
  PATH_OUT=${PATH_IN%.*}-processed.${EXTENSION}

  echo -e "\nProcessing:\n  $PATH_IN"
  echo -e "Output File:\n  $PATH_OUT"

  ((LEFT=(0 + $PAD)))
  ((RIGHT=$(identify -format '%w' $PATH_IN) - $PAD - 240))
  ((BOTTOM=$(identify -format '%h' $PATH_IN) - $PAD))

  STRING="$(exifshort $PATH_IN)"
  echo -e "\nBurning exif data to image"
  convert -pointsize $FONT_SIZE -fill yellow -draw "text 10,$BOTTOM '$STRING'" $PATH_IN $PATH_OUT
  echo -e "\nBurning watermark to image"
  convert -pointsize $FONT_SIZE -fill yellow -draw "text $RIGHT,$BOTTOM 'karnsonline.com'" $PATH_OUT $PATH_OUT
}

Running the scripts

To show the short version of a photos metadata you can run the following command:

$ exifshort path/to/image/file.jpg

To burn the short version of the photos metadata to the image, run the following command:

burnexif path/to/image/file.jpg

The result will be a new image sitting right next to your source image with the addition of -processed to the file name. This script WILL NOT modify the original image source.