This bit from the film Spectre of Hope has been on my mind recently:
This notion of capturing the world in what is cumulatively a very small amount of time is interesting to me, and I realized that, given that all of my digital photos record the exposure for each frame, I could calculate exactly how much actual time I have recorded. I wrote a script (details on that after the jump) to do just this for all the photos I've taken since I got my first camera in 2002, and the total exposure time for 27611 images is 2360.473 seconds, or a bit under 40 minutes. That I take the occasional long exposures inflates this figure to a certain extent, but even with that it's a small amount of time for something that feels a lot longer.
I used Ruby for this. For jpg images, it's easy using the exifr library:
Dir.glob(photo_dir + "/**/*.jpg") do |img| begin exposure = EXIFR::JPEG.new(img).exposure_time; rescue puts "Problem reading exif from file " + img next end if (exposure) total_exposure += exposure end end
However, once I started using RAW for all my pictures, it became more complicated, as the exifr library supports jpeg and tiff files only. I ended up parsing the Lightroom metadata files instead:
Dir.glob(photo_dir + "/**/*.xmp") do |img| doc = XML::Document.file(img); exposure = doc.find("//exif:ExposureTime", 'exif:http://ns.adobe.com/exif/1.0/').first.content exp = exposure.split('/') num = Rational(Integer(exp), Integer(exp)) total_exposure += num end
This took me a while to develop, as the XMP format is RDF, and I could not make REXML play nicely with it. LibXML did the job with no problems.