XMP InvariantCulture or CurrentCulture

April 5, 2008

Well it wasn’t to be all smooth sailing in my XMP adventure. It turns out dates will always be a problem in life. The BitmapMetadata class has a property DateTaken that is a string! When I copied the date from the backup file to the current file it was swapping the days and months around?

Whats wrong with this i thought?
destMetadata.DateTaken = sourceMetadata.DateTaken;

Download trusty Reflector to the travel laptop and voila!
It turns out the property getter uses DateTime.FromFiletime to get the string. It appears this uses the Current Culture to format the date. The setter parses the passed in value using Convert.ToDateTime(value, CultureInfo.InvariantCulture);

I maybe missing something and I am sure it is by design, but surely they could have used a consistent culture to save me from this? Especially on my honeymoon! :)
DateTime fromDate = Convert.ToDateTime(sourceMetaData.DateTaken, CultureInfo.CurrentCulture);
destMetadata.DateTaken = fromDate.ToString(CultureInfo.InvariantCulture.DateTimeFormat);


A Temporary Hiatus – XMP

April 5, 2008

It’s been about 6 months since I left BluFreeway and took to a life of beaches and relaxation that ones honeymoon brings. :)

The call of coding had nagged me into installing VS 2008 on our lightweight travel laptop to stay afresh of developments in the .NET space. When a small error on my behalf (no prompts for bulk changes in Vista’s Photo Gallery!!) corrupted all the dates of our wedding photos that Kahlia had painstakingly rated, tagged and categorised.

Smiling smugly i said “No Problem!”, knowing all I had to do was whip up some code to copy the dates from the originals we had backed up. A few minutes later I had some code to do such a task. I even knew about EXIF and how to access it. How proud I was off myself knowing all about this graphics stuff! To my dismay the app whilst changing the metadata did nothing towards fixing the problem in Vista. Apparenlty my knowledge was out of date.

Enter Adobes brain child, XMP, a new era in metadata apparently. Thankfully .NET 3.5 has a great set of classes to handle this, WPF. It made the whole process really simple in the end. If only the documentation was as good.

Know it’s back to the sand and surf for awhile yet.