Ruby script for focal length statistics
Posted in Photography on December 11th, 2008 by erik – 2 CommentsI 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.

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








