For the holidays I got a new Canon 7D camera. I’ve been saving quite a few amazon gift cards over the last year that I was previously planning on using towards purchasing the camera but thankfully Santa delivered me one. My current lens collection consists of
- 10-22mm f/3.5-4.5
- 70-200mm f/4
- 50mm f/1.8
- 18-55mm f/3.5-5.6 (kit lens) The lens collection has been built over the last 4 years from when I first got my Canon Rebel XT and I’ve been fairly happy with them thus far. As part of looking into what new lens to get I wanted to know what focal length I shot with the most over the previous years. A quick look with
find . -type f -name '*.CR2' | wc -l
shows I have 4697 RAW images in my photos folder, so I’ll need some sort of automated solution to figure this out.
My first inclination was to poke around Python’s PIL and see if it supported reading of RAW images, it didn’t appear to do so that option was out. I looked at the Canon RAW format at and contemplated doing some parsing of the files to extract the info I needed from the EXIF data. I remembered in the past I had used UFRaw to play around with RAW conversion in Linux a while back and saw they are using a nice simple tool to do their RAW parsing called dcraw. It’s a small C program that I was able to compile the source with the following commands…
sudo apt-get install libjpeg-dev liblcms-dev gcc -o dcraw -O4 dcraw.c -lm -ljpeg -llcms
Using dcraw seemed like the path of least resistance and now I just needed to wrap some code around it to go through all of my RAW images and extract the EXIF info and keep a hash table of the focal length value. I whipped up a small python script and posted a gist of it over on github.
It’s fairly straight forward and could easily be modified to do more, like collect aperture sizes or any other EXIF data. I may go back and build it out a bit more to make it more flexible in what data it collects, but for now this suited my needs at the time. My top 10 focal lengths ended up being
Total pics to process: 4697
Length: 50.0 Count: 1624
Length: 22.0 Count: 576
Length: 18.0 Count: 423
Length: 200.0 Count: 404
Length: 55.0 Count: 373
Length: 10.0 Count: 192
Length: 70.0 Count: 176
Length: 37.0 Count: 74
Length: 16.0 Count: 33
Takes close to 11 seconds on average to calculate that for 4697 images.
I had been wanting to upgrade my 50mm f/1.8 lens for a bit as I’d really started to notice the short comings of it. The lens has a hard time focusing and also had a bit of a back focusing issue. Since my Uncle borrows my camera a lot when he goes on vacation I worked out a deal with him to purchase the 50mm f/1.4 for me and in exchange I’d give him my old Canon Rebel XT with the kit lens and the 50mm f/1.8 lens.
The kit lens was a great walk about lens so I’m currently trying to decide on a good and reasonably priced lens to cover somewhere in the 18-100mm range. I’m reading through a bunch of comments on amazon reviews and dpreview forums to figure out what my best bang for my buck would be for a lens in that range.