A different kind of histogram


#1

Originally, I was wondering if I could replace my 120-400 zoom by a 300mm prime and a 1.4x multiplier. Since I can’t resist a good occasion to write a python script, I quickly wrote something to extract the relevant EXIFs from a collection of pictures, and with the help of LibreOffice, make a histogram from that.

So this is the histogram of all the Photos I have on my hard disk, pretty much all of 2018 and a good deal of 2017, plus a few older directories I haven’t archived yet. Some interesting findings:

  • I don’t use the 10-20mm that much
  • I don’t use my 1.4x multiplier that much either (the small bar around 560mm)
  • The long end of my 17-70mm is overworked. Maybe I should get a 24-105mm.
  • I do make a lot of shots in the 280-400mm range, but I do use the low end of the zoom quite a bit, too.

(Roel) #2

I’ve often wondered how this would look like for my own collection too. I think I might as well get prime lenses only, but I haven’t checked. Would you care to share your script?


#3

Barely fit for human consumption but here it is:

exifstats (845 Bytes)

Use as:

exifstats top_directory >stats.csv

Where top_directory is the parent directory of your collection of photographs.

Then load the CSV in your favorite spreadsheet for the rest (in LibreOffice, see the FREQUENCY function).

(note: you need the exifread module, and this is for PythonV3)


#4

It might be useful to have logarithmic spaced bins.


#5

You generate the bins in the spreadsheet, so you can use any scale you want. For my purpose I mostly wanted to see how I used the 120-400 range, and a logarithmic scale over the whole set of pics would not have had enough detail.

Edit: Here it is:


(Roel) #6

@Ofnuts Thank you for sharing the code. I was secretly hoping it would read raw files, but alas no… A man can dream :smile:


(Glenn Butcher) #7

I wrote a nice script to do this a few years ago; alas, lost it in my Ubuntui 18.04 upgrade… :frowning:

Anyway, here’s quick-n-dirty, using two tools: 1) exiftool, and 2) perl. Yes, perl, I’m that old. Both exiftool and perl install from the Unbuntu repositories; with that, put this script in /usr/local/bin:

#!/usr/bin/perl

$min=10000;
$max=0;
while ($val = <>) {
    next if $val !~ /Focal/;
    $val =~ s/^.+?://;
    $val =~ s/ mm//;
    chomp $val;
    $val = int $val;
    $histogram{$val}++;
    $min = $val if $val < $min;
    $max = $val if $val > $max;
}

for ($i=$min; $i<=$max; $i++) {
    print "$i: $histogram{$i}\n";
}

and run the following in the directory with all your raw files (NEFs in my example):

$ exiftool -S -FocalLength *.NEF | histogram.pl

Yes, not a pretty graph, but the relevant information is presented.

You just need exiftool, full stop. I make sure I have it, dcraw, and gmic (command line version) somwhere in my $PATH…


(Damon Lynch) #8

You can use this class to do that in Python: https://lazka.github.io/pgi-docs/GExiv2-0.10/classes/Metadata.html

You use it to call exiv2 from Python. Very handy!

For some example code, see: https://bazaar.launchpad.net/~dlynch3/rapid/zeromq_pyqt/view/head:/raphodo/metadataphoto.py


(Isaac Ullah) #10

Try using pandas, matplotlib, and seaborn to create the histogram, it will look a lot better than what you can make in calc, and will give you a 100% Pythonic way of making that plot in just one script. Cool idea, btw!

https://seaborn.pydata.org/tutorial/distributions.html


#11

It works on my CR2 files, just replace .JPG by .CR2 in the code.