Saturday 16 May 2009

A forward slash annoys me

I haven't blogged the last couple of days because I couldn't be bothered. Anyway I have something to 'blog' about now.

The last couple of days I've just been doing more work on my website, at the moment I'm still working on extracting metadata from the image and sticking it in the database. Yesterday I found the composite 'Lens' tag produced by exiftool isn't that great, e.g. [Lens] => 18.0-70.0 mm f/3.5-4.5. Now while that's good, it's not great. What I was looking for is more like [Lens] => AF-S DX Zoom-Nikkor 18-70mm f/3.5-4.5G IF-ED, which I believe is also a composite tag produced by exiftool, but it doesn't produce that tag with the options I'm currently using (-EXIF:all -XMP:all -g -j -c "%s" -E -fast).

Anyway, I started yesterday to create an XMPComboBox that would display a pre-defined list of lens values you define yourself, and then when you select what lens you took the photo with from the XMPComboBox, it would save it to the aux:Lens property of the image's XMP metadata.

I got that working, but then I was thinking more about this, and that it would be better to use the seperate MicrosoftPhoto:LensModel and MicrosoftPhoto:LensManufacturer tags to save the lens info, as that way you can filter your images to get all photos taken with a lens by a certain manufacturer. Using those two tags also allows you to see the Lens info in Windows Explorer: Working with Lens information using Exiftool and Windows Vista.

So that's what I've been working on today. I had to delete most of my work that I'd done on the aux:Lens XMPComboBox yesterday and start on it again, as I now needed to get the XMPComboBox to write two values (MicrosoftPhoto:LensModel and MicrosoftPhoto:LensManufacturer) compared to just the one value for aux:Lens.

After getting it working in so far as I could write lens values to the XMP using my custom file info panel, I found that my lens values weren't showing up in Jin Da Pin Doze Explorer or the details when viewing the file properties in Windows Dora The Explorer.

I tried adding the lens values to the file through the files properties dialog in windows explorer, and they displayed fine in windows explorer. But when viewing the 'Raw Data' in Bridge, I noticed that it was using a weird namespace prefix for the MicrosoftPhoto tags:
<rdf:Description rdf:about=""
xmlns:MicrosoftPhoto_1_="http://ns.microsoft.com/photo/1.0">
<MicrosoftPhoto_1_:LensModel>EF-S18-55mm f/3.5-5.6</MicrosoftPhoto_1_:LensModel>
<MicrosoftPhoto_1_:LensManufacturer>Canon</MicrosoftPhoto_1_:LensManufacturer>
</rdf:Description>


Googling for "MicrosoftPhoto_1_" did come up with a few (only one page of) results, but not much useful. I tried writing a LensModel value using Exiftool, and this too appeared in the 'Raw Data' panel of Adobe Bridge to use the MicrosoftPhoto_1_ namespace prefix.

Extracting the xmp with exiftool/exiftoolGUI, the namespace appeared to be MicrosoftPhoto, not MicrosoftPhoto_1_. This was the case for files with the LensModel value written through Windows Explorer, Exiftool, and my custom FileInfo panel for Bridge.

I also found that when Exiftool wrote the LensModel value, it would show up in windows explorer, unlike when written through my custom XMP File Info panel. I tried starting with an image with no metadata, in case some existing metadata value was messing it up, but still got the same results.

I also tried extracting the tags using Exiftool. Using -XMP:LensModel I could extract the lens model from my image that had the metadata written by my custom file info panel, but if I used -XMP-microsoft:LensModel, it wouldn't extract anything. Both methods would work okay on images where the LensModel was written by exiftool or windows. I also tried -XMP-MicrosoftPhoto:LensModel just in case, but that didn't work.

I tried using exiftool to extract the LensModel data from 2 images (one with the tag written by windows, the other with the tag written by my custom XMP FileInfo panel), and stick the data in an xmp file. When I compared them they were identical.
Image with LensModel set through custom FileInfo Panel in Adobe Bridge
Image with LensModel set in Windows Vista x64
(Both images should have metadata intact)

-XMP:LensModel data from the custom FileInfo panel image:
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 7.75'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about=''
xmlns:MicrosoftPhoto='http://ns.microsoft.com/photo/1.0'>
<MicrosoftPhoto:LensModel>24mm f2.8</MicrosoftPhoto:LensModel>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>


-XMP:LensModel data from the Windows image:
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 7.75'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about=''
xmlns:MicrosoftPhoto='http://ns.microsoft.com/photo/1.0'>
<MicrosoftPhoto:LensModel>24mm f/2.8</MicrosoftPhoto:LensModel>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>


Now, when comparing the two files I noticed that the namespace URI for the MicrosoftPhoto namespace doesn't end in a forward slash or hash/pound sign. According to the XMP specification (bottom of page 14):
The namespace URI for an XMP Schema must obey the rules for XML 1.1 namespaces. In addition, to operate well with RDF it must end with a ‘/’ or ‘#’ character.


In my custom XMP FileInfo panel, I had set the MicrosoftPhoto namespace URI to end in a forward slash, as per the Exiv2 page for the Microsoft Photo Schema that I got the namespace URI from. But when exiftool extracted the xmp, it was missing this forward slash from the end of the namespace URI.

I checked the 'Raw Data' for the two files in Bridge, and noticed there that the file where I had saved the LensModel through my custom File Info Panel did have a forward slash on the end of the MicrosoftPhoto namespace URI, whilst the image with the LensModel added through the Windows File Properties dialog was missing the forward slash from the end of the MicrosoftPhoto_1_ namespace URI.

All this testing and messing around with this took me quite a while. Anyway, seeing this I tried changing the namespace URI for MicrosoftPhoto so it didn't have a trailing slash. And hey, Presto! Get your hands off my Pogs! Sorry, just talking to Presto there. Well, it worked. I guess I should have known that Microsoft would not adhere to the standards. And it's not like adding a trailing slash or # on the end of your namespace URI is difficult. <sarcasm>Thanks for wasting a few more hours of my time MS!</sarcasm>

Also today I watched 2 episodes each of The New Super Mario World and The Tick Live Action with Moccle and Lad, went on Animal Crossing for a while, watched Moccle go on Paper Mario and Zelda for a bit, and did a bit of gardening. Shaz MacPeeaz came home today as well.

The weather today was mainly cloudy, and it rained quite a few times.

Food
Breakfast: Blackcurrant jam toast sandwich; cup o' tea.
Lunch: Piece of fresh bread-maker-made bread with cheese and iceberg lettuce; Piece of fresh bread-maker-made bread with honey; slice of Tate & Lyle's Golden Syrup Cake; Caramel Rocky; Cup o' tea.
Dinner: Slice of Pepperoni Pizza; peas; chips; salt. Pudding was a big chocolate choc chip cookie. Coffee; small piece of easter egg.
Supper: Dark chocolate digestive; cup o' tea.

1 comment:

Unknown said...

A million thanks for taking the time to write this up. There is a lot of valuable info here--I'm working with lens tags & Vista XMP, too.