Programatically pull EXIF info and produce camera setting statistics for a bunch of images

Last time out wakeboarding, I brought out my 30D and we shot over a thousand photos. I noticed that the best shots of the day were Brant's and that some of my shots were a little soft. To help me figure out the settings which led to softness, I wanted to dump each photo's settings into a file to quickly grep and to get some overall stats. Here's one way to do it.

mnt="/media/EOS_DIGITAL/DCIM/103CANON"
tmp="/tmp/camera.settings.txt"
for f in $(ls $mnt/*.JPG); do 
  name=$(basename $f)
  vars=$(exiftags $f | grep "Exposure Time\|F-Number\|Focal Length\|ISO Speed Rating")
  settings=$(echo "$vars" | sed 's/$/|/g')
  echo $name"|"$settings >> $tmp
done

Which produces:

foo@bar:~$ head /tmp/camera.settings.txt
IMG_6264.JPG|Exposure Time: 1/1250 sec| F-Number: f/4.0| ISO Speed Rating: 160| Focal Length: 70.00 mm|
IMG_6265.JPG|Exposure Time: 1/1250 sec| F-Number: f/4.0| ISO Speed Rating: 160| Focal Length: 70.00 mm|
IMG_6266.JPG|Exposure Time: 1/1250 sec| F-Number: f/4.0| ISO Speed Rating: 160| Focal Length: 70.00 mm|
IMG_6267.JPG|Exposure Time: 1/1250 sec| F-Number: f/4.0| ISO Speed Rating: 160| Focal Length: 70.00 mm|
IMG_6268.JPG|Exposure Time: 1/1250 sec| F-Number: f/4.0| ISO Speed Rating: 160| Focal Length: 70.00 mm|
IMG_6269.JPG|Exposure Time: 1/1250 sec| F-Number: f/4.0| ISO Speed Rating: 160| Focal Length: 159.00 mm|
IMG_6270.JPG|Exposure Time: 1/1250 sec| F-Number: f/4.0| ISO Speed Rating: 160| Focal Length: 159.00 mm|
IMG_6271.JPG|Exposure Time: 1/1250 sec| F-Number: f/4.0| ISO Speed Rating: 160| Focal Length: 159.00 mm|
IMG_6272.JPG|Exposure Time: 1/1250 sec| F-Number: f/4.0| ISO Speed Rating: 160| Focal Length: 159.00 mm|
IMG_6273.JPG|Exposure Time: 1/1250 sec| F-Number: f/4.0| ISO Speed Rating: 160| Focal Length: 109.00 mm|

Get some stats.

Focal length:

foo@bar:~$ grep -Eo "[0-9]{2,3}\.[0-9]{2}\ mm" $tmp | sort | uniq -c | sort -nr
    159 122.00 mm
    115 100.00 mm
    112 113.00 mm
    100 126.00 mm
     99 131.00 mm
     87 109.00 mm
     76 118.00 mm
     68 98.00 mm
     64 140.00 mm
     59 200.00 mm
     52 104.00 mm
     40 94.00 mm
     40 168.00 mm
     38 154.00 mm
     38 135.00 mm
     24 91.00 mm
     22 159.00 mm
     18 149.00 mm
     11 145.00 mm
      9 84.00 mm
      9 163.00 mm
      6 70.00 mm
      5 172.00 mm
      4 73.00 mm

Aperture:

foo@bar:~$ grep -Eo "f\/[0-9]{1,2}\.[0-9]{1,2}" $tmp | sort | uniq -c | sort -nr
   1087 f/4.0
    146 f/4.5
     13 f/5.0
      9 f/5.6

ISO:

foo@bar:~$ awk '{print$10}' $tmp | sed 's/|//' | sort | uniq -c | sort -nr
    632 200
    358 250
    133 320
     99 160
     16 125
     14 100
      3 400

Leave a comment

NOTE: Enclose quotes in <blockquote></blockquote>. Enclose code in <pre lang="LANG"></pre> (where LANG is one of these).