Read/Write JPEG metadata

by Marcel Wijnands 10. November 2008 00:46

I expected to find a lot of information and examples about reading and writing JPEG metadata when I started searching the net. However I couldn't find much. After finding a great blog entry by Robert A. Wlodarczyk I created a useful Class that can be used in both ASP.NET and Windows Forms / WPF applications. Please note I'm always using VB 9.0's type inference, I love it because it's less typing ;)

To read or write metadata to a JPEG, use the JpegMetaData's constructor to open the file;

Dim myMetaData = New JpegMetaData(Server.MapPath("Photo.jpg"))

My basic class supports only 5 properties, but you could extend it;

myMetaData.Title = "My Title"
myMetaData.Subject = "My Subject"
myMetaData.Rating = 4
myMetaData.Keywords = (New String() {"Keyword1", "Keyword2"}).ToList
myMetaData.Comments = "My Comments"

the metadata is not saved until the save function is called, which will return a boolean to indicate wether the save succeeded;

Dim isSaved = myMetaData.Save()

JpegMetaData can be downloaded below;

JpegMetaData.zip (1.71 kb)

Tags:

ASP.NET | VB.NET | WPF

Comments

3/12/2009 5:27:41 PM #

Mehmet Özakan

Thanks for the code. It really works fine at 3.0 . What about 2.0 , did you try to run it there ?

Mehmet Özakan Turkey

3/16/2009 7:23:30 PM #

Marcel Wijnands

Mehmet, since it uses 3.0 assemblies it cannot run in 2.0.

Marcel Wijnands Netherlands

3/22/2009 10:10:06 PM #

Mehmet Ozakan

I did it run at 2.0 by making small changes at the source code. I want it to be shared on your blog since it belongs to you. I will send the code soon.

Mehmet Ozakan Turkey

10/3/2009 1:00:31 AM #

shyNET|Reviews

..

shyNET|Reviews United Kingdom

Comments are closed

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen | Modified by Mooglegiant