In Valid Logic

Endlessly expanding technology

Improving EXIF handling in Community Server

For a while now, I’ve been growing frustrated with some of the EXIF support in Community Server.  Originally, it used the ImageProperties attributes that go along with System.Drawing.Image.  However, in order to read those values, the image had to be completely processed into an Image object, and when we created the FTP Server add-on, bulk uploads would nearly peg the CPU while processing everything.

The solution was to adapt a way of reading the properties raw from the image, without having to process the whole thing.  There was a lack of .NET based EXIF libraries, but I did manage to find Drew Noakes’ library, which was in Java, but it did have a C# port.  So I cannibalised the port to get what we needed (mainly stripped it down and changed it to use XML resource files).  I had plans to add in the code other things like IPTC and manufacturer specific tags, but never got to it.  The way it was working was still frustrating, as it would often show properties like “Flash: 16”.  What does that mean?  Well, 16 stood for something, but it wasn’t able to process those individually.

Then I got my new Digital Rebel XT.  Upon uploading my first pictures, I found none of the EXIF tags were showing.  After some testing, it was causing a stack overflow exception due to a cyclic EXIF directory.  This was a bug in the core library.  Luckily, a few days before I found this, Drew released a new version of his Java library with this issue fixed… but nothing about an updated C# port.

So what is a desperate coder to do?  Port it themselves!  It took me a couple night here there over the past few weeks to get it done, but finally got it all ported to C#.  Porting Java to C# is so boring.  I’m not fully done yet, as naming conventions are still wrong (getTagName() as opposed to GetTagName()).  Surprisingly, it worked pretty much right away… except for some certain images.

My normal picture workflow now is take pictures in RAW, open in Photoshop to adjust white balance, reduce noise, and often resize… then I save as a TIFF, and then fire up FastStone Photo Resizer to convert them all to JPEG and to carry over the EXIF data.  The problem was that the library wasn’t reading any EXIF properties from these files.  Fast forward a couple of hours of debugging and researching, I found the bug in the library (was checking the size of a EXIF directory wrong), and it is working great!

Now fast forward another couple hours of hacking things apart, and I finally managed to get it built into my Community Server build.  So now you get far more proper EXIF values, such as these.  Complete with IPTC, support for Canon, Nikon, Sony, Olympus, Pentax, and a bunch of other manufactures.

This support is not going to be in Community Server v2.0 RTM though.  It is far to late to throw this into the source, and I haven’t even fully tested it, or changed it to use our XML resource files.  But I will probably be looking into releasing it after CS RTMs, though it will certainly not be an update for the faint of heart.

Overall, I’d love to see the Photo Galleries in CS expand far greater and be a serious option for photo enthusiasts, and fully featured EXIF support is definitely a big step in that direction.

Friday, February 03, 2006

blog comments powered by Disqus