<?xml version="1.0" encoding="UTF-8"?>
<essay xml:lang="en" version="5.0" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:gal="http://norman.walsh.name/rdf/gallery#" xmlns:foaf="http://xmlns.com/foaf/0.1/">
<info>
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
<title>Photographic metadata</title><biblioid class="uri">http://norman.walsh.name/2007/08/31/photometadata</biblioid>
<volumenum>10</volumenum>
<issuenum>87</issuenum>
<pubdate>2007-08-31T12:22:18-04:00</pubdate>
<date>$Date$</date>
<author>
      <personname>
<firstname>Norman</firstname>
	<surname>Walsh</surname>
</personname>
    </author>
<copyright>
      <year>2007</year>
      <holder>Norman Walsh</holder>
    </copyright>
<abstract>
<para>Metadata, metadata, where's my photographic metadata? In EXIF.
In RDF. In RDF in EXIF. In RDF. In EXIF. In Lightroom. More or less.
</para>
</abstract>
<dc:subject rdf:resource="http://norman.walsh.name/knows/taxonomy#Lightroom"/>
<dc:subject rdf:resource="http://norman.walsh.name/knows/taxonomy#Photography"/>
</info>

<para xml:id="p1">When I first started working with digital images, I
was delighted that useful metadata was stored within them. Back in my
film days, I used to try to keep a record of exposure information,
developing information, etc., but I was never very successful. I
have all the negatives from those days but none of the
notes.</para>

<para xml:id="p2">Having some metadata motivated me to keep more and I began
trying to maintain information about who (or what) was in each photo
and where it was taken. Following the lead of projects like
<link xlink:href="http://rdfweb.org/2002/01/photo/">the co-depiction
experiment</link>, I stored the metadata in RDF. (The RDF data model
is well suited to photographic metadata; what you're storing are the
values of properties about the photo: in a word “triples”.)</para>

<para xml:id="p3">Unhappy with having to maintain images and metadata in separate
files, I cooked up
<link xlink:href="/2005/projects/jpegrdf">JpegRDF</link>
to store the RDF metadata in the images, using the
<wikipedia page="Exchangeable_image_file_format">EXIF</wikipedia>
comment field.</para>

<para xml:id="p4">That worked pretty well for several years. But when I started
shooting raw images, two things happened. First, I couldn't easily put the
RDF in the images. Raw images have EXIF metadata, but
<command>JpegRDF</command> couldn't write to them. Second, the files got a
lot bigger so processing them was noticably slower.</para>

<para xml:id="p5">My initial fallback position was to return to storing the RDF
metadata in separate files.</para>

<para xml:id="p6">I had <link xlink:href="http://norman.walsh.name/2006/09/13/photodata">high
hopes</link> for <link xlink:href="http://photodata.org/">photodata.org</link>
but it didn't really pan out. I think there's an interesting web application
in there somewhere, but I couldn't find it. And when an Ubuntu upgrade
<link xlink:href="https://bugs.launchpad.net/ubuntu/+source/redland-bindings/+bug/102845">completely broke it</link>, I gave up. At least for now, I don't
promise never to return to it.</para>

<para xml:id="p7">One of the reasons to
<link xlink:href="http://norman.walsh.name/2007/08/15/IMac">switch</link>
was to try out commercial solutions to this problem. I selected
<wikipedia page="Adobe_Photoshop_Lightroom">Lightroom</wikipedia> partly
because I read that it stored its database in
<wikipedia>SQLite</wikipedia> and
<link xlink:href="http://norman.walsh.name/2007/06/08/digikam">I knew</link>
I could turn that to my advantage if I needed to. (In fairness, the
other contender, Aperature, may store its data in SQLite too, I don't know.)
</para>

<para xml:id="p8">Lightroom stores a really impressive collection of metadata.</para>

<para xml:id="p9">The question was, how to turn several tens of megabytes of RDF
into something useful in Lightroom. I had imagined that this would
involve pouring over the database SQL with Perl, but it turned out to
be much simpler.</para>

<para xml:id="p10">First, I had to simply accepted a couple of shortcomings.</para>

<itemizedlist>
<listitem>
      <para xml:id="p11">Lightroom doesn't seem to provide any way to keep and
edit the EXIF comment field. In the past, I've used that to store
abitrary metadata, which is probably what I would have done if I could.
Everything has to go in Lightroom's fields. Luckily, there's a lot of
room and provisions in the EXIF (<wikipedia page="International_Press_Telecommunications_Council">IPTC</wikipedia>,
etc.) metadata hold keywords, locations, etc.</para>
</listitem>
<listitem>
<para xml:id="p12">In RDF, you can easily distinguish between a specific thing and
an instance of a class of things. That is “Norman Walsh”, a specific
person, on the one hand and “a bird”, not some particular bird, but an
anonymous exemplar of that class, on the other. (It's the sort
of technical detail that I'm just anal-retentive enough to care about.)</para>

<para xml:id="p13">If there's a way to maintain this in Lightroom, I don't see how.
I gave up. I turned them all into keywords and will work out which is
which later if I need to. I try to identify things with URIs from
WordNet or Wikipedia; those are mostly examples of anonymous exemplars.
For people and events, I make up my own URIs. For locations, Lightroom
stores the actual street addresses.
</para>
</listitem>
</itemizedlist>

<para xml:id="p14">The simpler bit I alluded to earlier is the fact that
<personname>
      <firstname>Phil</firstname>
<surname>Harvey</surname>
    </personname>’s excellent
<link xlink:href="http://www.sno.phy.queensu.ca/~phil/exiftool/">ExifTool</link>
can write all the EXIF metadata that Lightroom can read. Even the
street addresses and
<wikipedia page="Global_Positioning_System">GPS</wikipedia> coordinates!</para>

<para xml:id="p15">So I turned <code>foaf:depicts</code> and
<code>dc:subject</code> into EXIF keywords; I extracted the GPS
coordinates out of <code>dcterms:spatial</code>; and I turned
<code>dc:coverage</code> URIs into street addresses. (The RDF
in my
<link xlink:href="http://norman.walsh.name/2003/12/11/practicalrdf">personal
information manager</link> made the mapping easy.)</para>

<para xml:id="p16">Having massaged all the RDF metadata from several thousand
images back into EXIF, I loaded them up into Lightroom and,
lo and behold, it all just worked.</para>

<para xml:id="p17">My only tactical error was representing WordNet and Wikipedia 
URIs as keywords with colons. So “Flowers” from WordNet was represented
with the keyword “<code>wn:Flowers</code>”.</para>

<para xml:id="p18">It turns out that when you're entering metadata in Lightroom, it
interprets the “:” like a “,” and “completes” whatever keyword you're
typing. So I used my Perl-grovel-over-SQL trick after all to rename all
the keywords with colons into keywords with hyphens.</para>

<para xml:id="p19">So my new workflow is:</para>

<orderedlist>
<listitem>
<para xml:id="p20">Move images off the camera:</para>
<screen>$ copycf</screen>
<para xml:id="p21">(My <command>copycf</command> script actually needs a little work,
but let's pretend. The name, by the way, is a holdover from when I used
to copy data off a <wikipedia>CompactFlash</wikipedia> card.
With my <wikipedia>Nikon D80</wikipedia>, I just copy them straight off
the camera.)</para>
</listitem>
<listitem>
<para xml:id="p22">Apply batch metadata, including GPS track information, if there
is any.</para>
<screen>$ <link xlink:href="examples/toxmp">toxmp</link> -a -2:30 *.nef dc:subject=wn:Bald_eagle dc:coverage=us-ma-south-hadley</screen>
<para xml:id="p23">(Note that I still use the colon forms outside of Lightroom.)</para>
</listitem>
<listitem>
<para xml:id="p24">Import the photos into Lightroom.</para>
</listitem>
<listitem>
<para xml:id="p25">Add more metadata as appropriate, select the good photos,
“develop” them, and export them as JPEGs.</para>
</listitem>
<listitem>
<para xml:id="p26">If they're going to Flickr, upload them.</para>
<screen>$ <link xlink:href="examples/flickrpub">flickrpub</link> -public 1 *.jpg</screen>
</listitem>
</orderedlist>

<para xml:id="p27">And it works! See:</para>

<mediaobject role="flickr">
    <!--Bald eagle-->
  <imageobject xlink:href="http://www.flickr.com/photos/ndw/1276868722/">
    <imagedata fileref="http://farm2.static.flickr.com/1090/1276868722_d9033bae45.jpg"/>
  </imageobject>
</mediaobject>

<para xml:id="p28">I've noticed that <link xlink:href="http://www.flickr.com/">Flickr</link>
actually extracts the keywords (e.g., the <code>wn-</code>* ones) from
the EXIF. I haven't figured out what to do about that.</para>

</essay>

