In making my add to anything photo gallery I'm shooting for zero config.  I want the photo album to essentially be able to go into any existing web application out there and be configured and ready to rock in less than a minute.  I honestly don't think it's that tough to do, just a few controls and it should be good to go.

The problem I was getting into, is I wanted to have a photo information control within everything.  Bill Pierce suggested SQLite (or more technically System.Data.SQLite) an embedded database.  This would allow me to store whatever information I wanted, but then I got to thinking.  We all don't want to store all of this information on a website, as our photo collection's real home is on our hard drives, that is backed up to other places that usually the public won't see.  The best place to store the information would be to be inside of the photo itself.

I started looking at the EXIF (or Metadata) information, and this is exactly what would be the best solution.  You know the stuff that looks like:

image

or

image

or even:

image

I essentially started with all of the existing EXIF extracting code that other people have written.  The problem was, these KEY fields weren't being extracted.  Why?  Because they aren't standard.  Microsoft came up with their own EXIF fields, and decided to change the way they were encoded.  How very helpful.

Anyway, I figured it out, by piecing together a bunch of different code examples, web sites, forum posts, blog posts, etc.  And here it is in snippet form.  First you have your constants:

public enum PropertyTagId: int
{

    // The following items correspond to the EXIF IDs that
    // are set by windows file explorer when edited in the
    // properties dialog summary page.
    WindowsTitle = 0x9c9b,
    WindowsSubject = 0x9c9f,
    WindowsKeywords = 0x9c9e,
    WindowsComments = 0x9c9c,

...

and then you have your properties that are derived from that.

_image= System.Drawing.Image.FromFile(imageFileName);

...

public string WindowsTitle
{
    get
    {
        System.Text.Encoding enc = System.Text.Encoding.UTF8;
        return enc.GetString(_image.GetPropertyItem((int)PropertyTagId.WindowsTitle).Value).Replace("\0", "").Trim();
    }
}

This allows you to do this in your website:

image

Looks so easy, and is, but just finding this information out took for-ev-er.