Tip: Reusing metadata from your images

Sep 26, 2009 at 7:41 PM

The sample JFDZ provided (and the deepzoompix demo unfortunately) do not reuse EXIF style metadata in your images.  So if you've been using WIndows live gallery or other methods to tag images and give them data which is contained in the image format (this is for xpsp3, vista, or higher) then it doesnt get populated to the Jellyfish sample project database.

The WIC (windows imaging component) allows you to access this data, but I couldnt find a way to do it quick and easily outside of WPF, so I hacked up something quickly that got me the info..heres my steps (if someone knows better steps please share!).  The wpf namespace is System.

1) I created a project that was a WPF windows application...but then set the output type to 'console'.  This app is meant to take a filename on the command line, and return a comma separated 'tag list'.  This could be extended to also return title, camera info, etc. for later jfdz work.

2) I commented out the initialize component, used System.environment.getcommandlineargs() to grab the commandline, and then snagged the first param from there.

Then I did: (This is modified by myself  from: http://www.wiredprairie.us/journal/2007/04/photoscroll_the_worst_named_wp.html by Aaron who had some great info on this topic)

            FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
            BitmapSource bitmapSource = BitmapFrame.Create(fs);
            BitmapMetadata bitmapData = (BitmapMetadata)bitmapSource.Metadata;
            string returnTagString = "";
            foreach (string tag in bitmapData.Keywords)
                if (returnTagString != "")
                    returnTagString += ",";
                returnTagString += tag;
            return returnTagString;

Then over in admin\upload_image.aspx, below the Execute SDIConverter section, I add...

                    startInfo = new ProcessStartInfo(GetPhysicalPath(@"Bin\GetMetaDataWPF\GetMetaDataWPF.exe"));
                    startInfo.Arguments = uploadFilesPath + Path.GetFileName(savedSourceFileName);
                    startInfo.WindowStyle = ProcessWindowStyle.Hidden;
                    startInfo.UseShellExecute = false;
                    startInfo.RedirectStandardOutput = true;
                    _Process = Process.Start(startInfo);                    

                    // Waiting until this process will exit...
                    // append 'found tags' to the tags listed.
                    // Note: should remove dupes in the future?
                    string tags = _Process.StandardOutput.ReadToEnd();
                    tagTextBox += "," + tags;
This is very quick, very dirty, but a good way to extend the existing sample to be 'smarter'.  Then using your favorite tagging app, you can tag your photos on your pc, 
and when you upload them to the web the images will already be tagged.
Next up: Batch uploading..this one at a time stuffs killing me :)

Apr 21, 2010 at 8:39 AM

Not Bad.