…mostly photography, dance and a bit of computery stuff

Ruby script for focal length statistics

I have wanted to get a fast prime lens for a while, but wasn’t sure whether to go for Canon’s 50mm f/1.2, 35mm f/1.4 or the new 24mm f/1.4 II to put on my EOS 50D. I had an idea that wider lens would support my style of photography better, because I often shoot dancing indoors, where it’s hard to get a good distance to the subject, but I had no hard data to back it up.

I use Adobe Lightroom for almost all my image editing, and although it is a fantastic piece of software, and can show me picture counts by lens, camera, etc., it cannot show me how many pictures I’ve taken at various focal lenghts.

So I wrote a small Ruby script to do just that. It takes a folder and a result file name as arguments, and scans through the folder for any pictures that matches the file type (jpg or raw) and the camera model I’m interested in (to filter out the compact), and counts all the focal lengths used, and their frequency. It then stores the results in the result file in CSV format.

If you like, you can download the script here. There is also an example result file, which shows a run of all the pictures I’ve taken in 2008. The script uses the mini_exiftool gem that wraps the exiftool binary, so you’ll need both to run the script.

I just love how simple it is to put these kind of utilities together with Ruby. You are welcome to modify the script as you like, and I’d like to hear about any improvements or other cool stuff you come up with.

The image below shows a graph over the 6608 pictures I’ve have kept, taken with my Canon EF-S 17-55mm f/2.8 IS, over the last 1 1/2 years. This is the lens that I use for 75% of my pictures.

result_all_years

This shows a couple of interesting things (at least to me):

  • I primarily use the lens at it extremes: 17mm and 55mm
  • I clearly prefer the wider focal lengths, from 17-35mm

So now I am sure that it is the Canon 24mm f/1.4 II that should be on my wishlist – now I just have to save up for it :-)

2 Responses to “Ruby script for focal length statistics”

  1. alan says:

    Nicely done! I know it’s somewhat reductionist, but I think there’s a lot to learn from the data that our photography produces. Using exiftool to pull the stats on a folders’ images is a nice idea. I took a different route to extract data from my own LR database — some sqlite and R tinkering does it for me, and was a fun project to explore.

  2. erik says:

    Hi Alan, and thanks for the comment. It’s an interesting writeup you have, and though this kind of reduction doesn’t show us where to go, I find it useful, or at least interesting for the statistically inclined, to reflect on where we have been, and what focal lengths we tend to use most.

    Thanks for stopping by, and happy shooting :-)

Leave a Reply