Click here to Skip to main content
6,822,613 members and growing! (16,328 online)
Email Password   helpLost your password?
Multimedia » GDI+ » General     Intermediate

A library to simplify access to image metadata

By George Mamaladze

A library to simplify access to image metadata.
C#, Windows, .NET1.0, .NET1.1, GDI+, VS.NET2003, Dev
Posted:3 Aug 2004
Views:107,839
Bookmarked:81 times
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
25 votes for this article.
Popularity: 6.45 Rating: 4.62 out of 5
1 vote, 4.0%
1

2
2 votes, 8.0%
3
4 votes, 16.0%
4
18 votes, 72.0%
5

Introduction

Several image file formats enable you to store metadata along with an image. Metadata is information about an image, for example, title, width, camera model, and artist. Microsoft Windows GDI+ provides a uniform way of storing and retrieving metadata from image files in the Tagged Image File Format (TIFF), JPEG, Portable Network Graphics (PNG), and Exchangeable Image File (EXIF) formats. In GDI+, a piece of metadata is called a property item, and an individual property item is identified by a numerical constant called a property tag.

In .NET Framework, you can store and retrieve metadata by calling the SetPropertyItem and GetPropertyItem methods of the Image class, and you don't have to be concerned with the details of how a particular file format stores that metadata.

Another question is how can you use this data. You will receive just an array of bytes, and it is your problem how you interpret it. This library will simplify access to this image metadata by converting them to ordinary .NET data types and organizing them in the form of class properties and/or hashtable.

The primary source of information to write this class was MSDN.

MSDN Home > MSDN Library > Graphics and Multimedia > GDI+ > GDI+ Reference > Constants

I'd like also to thank Jeffrey S. Gangel whose article "Photo Properties" at CodeProject brought me to the idea to write this class. His program makes basically the same, the only difference is that I wanted to have image information in the form that seems to me to be more comfortable and conventional.

Not all image property tags are implemented as class properties. Those are accessible only from PropertyItems hashtable. If anyone needs this library at all and even needs the specific property, I'll be very glad to help him. But I think it is not necessary, because the whole source code is available and modifiable.

Usage

// Accessing image proprties

public void ShowEquipModel() 
{ 
    Info inf=new Info("c:\\tmp\\Example.jpeg"); 
    MessageBox.Show(inf.EquipModel);
}
// Accessing image proprties as a hastable 

public void ShowAllProperties() 
{ 
    Info inf=new Info("c:\\tmp\\Example.jpeg");
    listView.Items.Clear(); 
    foreach (string propertyname in inf.PropertyItems.Keys) {
        ListViewItem item1 = new ListViewItem(propertyname,0);
        item1.SubItems.Add((inf.PropertyItems[propertyname]).ToString());
        listView.Items.Add(item1); 
    } 
}

The properties of the Info class are listed below:

  • Brightness

    Brightness value. The unit is the APEX value. Ordinarily, it is given in the range of -99.99 to 99.99.

  • Copyright

    Copyright information.

  • DateTime

    Date and time the image was created.

  • DTDigitized

    Date and time when the image was stored as digital data. If, for example, an image was captured by DSC and at the same time the file was recorded, then DateTimeOriginal and DateTimeDigitized will have the same contents.

  • DTOrig

    Date and time when the original image data was generated. For a DSC, the date and time when the picture was taken.

  • EquipMake

    The manufacturer of the equipment used to record the image.

  • EquipModel

    The model name or model number of the equipment used to record the image.

  • ExposureProg

    Class of the program used by the camera to set exposure when the picture is taken.

  • FNumber

    F number.

  • FocalLength

    Actual focal length, in millimeters, of the lens. Conversion is not made to the focal length of a 35 millimeter film camera.

  • Image

    Sets or returns the current Image object.

  • ISOSpeed

    ISO speed and ISO latitude of the camera or input device as specified in ISO 12232.

  • MeteringMode

    Metering mode.

  • Orientation

    Image orientation viewed in terms of rows and columns.

  • PixXDim

    Type is PropertyTagTypeShort or PropertyTagTypeLong. Information specific to compressed data. When a compressed file is recorded, the valid width of the meaningful image must be recorded in this tag, whether or not there is padding data or a restart marker. This tag should not exist in an uncompressed file.

  • PixYDim

    Type is PropertyTagTypeShort or PropertyTagTypeLong. Information specific to compressed data. When a compressed file is recorded, the valid height of the meaningful image must be recorded in this tag whether or not there is padding data or a restart marker. This tag should not exist in an uncompressed file. Because data padding is unnecessary in the vertical direction, the number of lines recorded in this valid image height tag will be the same as that recorded in the SOF.

  • PropertyItems

    Returns a HashTable of all available properties of a given Image. Keys of this HashTable are display names of the Property Tags, and values are transformed (typed) data.

  • ResolutionUnit

    Unit of measure for the horizontal resolution and the vertical resolution. 2 - inch 3 - centimeter.

  • XResolution

    Number of pixels per unit in the image width (x) direction. The unit is specified by PropertyTagResolutionUnit.

  • YResolution

    Number of pixels per unit in the image height (y) direction. The unit is specified by PropertyTagResolutionUnit.

See also

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

George Mamaladze


Member

Occupation: Software Developer (Senior)
Location: Germany Germany

Other popular GDI+ articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 41 (Total in Forum: 41) (Refresh)FirstPrevNext
GeneralCan I use this dll? Pinmemberu85210012:10 30 Sep '08  
AnswerRe: Can I use this dll? PinmemberGeorge Mamaladze12:21 30 Sep '08  
GeneralProblem - Image files are left locked PinmemberjohnieT4:50 23 Sep '08  
GeneralRe: Problem - Image files are left locked PinmemberjohnieT2:15 24 Sep '08  
QuestionTerms of Use? PinmemberOmnicoder15:19 22 Apr '08  
AnswerRe: Terms of Use? PinmemberGeorge Mamaladze10:22 23 Apr '08  
Questionsome EXIF data not being read on some files? Pinmembertodd_00115:50 16 Jan '08  
GeneralRe: some EXIF data not being read on some files? PinmemberGeorge Mamaladze23:56 16 Jan '08  
GeneralRe: some EXIF data not being read on some files? Pinmembertodd_0019:58 17 Jan '08  
GeneralRe: some EXIF data not being read on some files? PinmemberGeorge Mamaladze11:06 17 Jan '08  
GeneralRe: some EXIF data not being read on some files? Pinmembertodd_00116:57 19 Jan '08  
GeneralRe: some EXIF data not being read on some files? Pinmembertodd_00119:21 19 Jan '08  
GeneralGreat work PinmemberDavorin Sajnovic0:55 22 Apr '07  
GeneralI used it, get the source Pinmembermotisaadon0:27 20 Mar '07  
GeneralResolutionUnit Pinmemberdamoose753:26 21 Dec '06  
GeneralSpeed ups [modified] Pinmemberlummie8:53 25 Oct '06  
GeneralExtract image (tiff and jpg) metadata Pinmembermindang21:03 15 Oct '06  
GeneralRe: Extract image (tiff and jpg) metadata PinmemberGeorge Mamaladze22:18 15 Oct '06  
GeneralRe: Extract image (tiff and jpg) metadata Pinmembermindang17:02 16 Oct '06  
GeneralRe: Extract image (tiff and jpg) metadata Pinmembermindang17:43 16 Oct '06  
Generalowner url Pinmemberwijesijp6:47 6 Sep '06  
QuestionHow would i write this in Visual Basic? Pinmembermac.macananny5:32 18 Aug '06  
AnswerRe: How would i write this in Visual Basic? PinmemberGeorge Mamaladze6:52 23 Aug '06  
AnswerRe: How would i write this in Visual Basic? PinmemberAlenCroatia2:09 24 Nov '08  
GeneralRe: How would i write this in Visual Basic? PinmemberGeorge Mamaladze4:48 24 Nov '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.

PermaLink | Privacy | Terms of Use
Last Updated: 3 Aug 2004
Editor: Smitha Vijayan
Copyright 2004 by George Mamaladze
Everything else Copyright © CodeProject, 1999-2010
Web17 | Advertise on the Code Project