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.
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:BrightnessBrightness value. The unit is the APEX value. Ordinarily, it is given in the range of -99.99 to 99.99.
CopyrightCopyright information.
DateTimeDate and time the image was created.
DTDigitizedDate 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, thenDateTimeOriginalandDateTimeDigitizedwill have the same contents.
DTOrigDate and time when the original image data was generated. For a DSC, the date and time when the picture was taken.
EquipMakeThe manufacturer of the equipment used to record the image.
EquipModelThe model name or model number of the equipment used to record the image.
ExposureProgClass of the program used by the camera to set exposure when the picture is taken.
FNumberF number.
FocalLengthActual focal length, in millimeters, of the lens. Conversion is not made to the focal length of a 35 millimeter film camera.
ImageSets or returns the currentImageobject.
ISOSpeedISO speed and ISO latitude of the camera or input device as specified in ISO 12232.
MeteringModeMetering mode.
- Orientation Image orientation viewed in terms of rows and columns.
PixXDimType isPropertyTagTypeShortorPropertyTagTypeLong. 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.
PixYDimType isPropertyTagTypeShortorPropertyTagTypeLong. 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.
PropertyItemsReturns aHashTableof all available properties of a givenImage. Keys of thisHashTableare display names of the Property Tags, and values are transformed (typed) data.
ResolutionUnitUnit of measure for the horizontal resolution and the vertical resolution. 2 - inch 3 - centimeter.
XResolutionNumber of pixels per unit in the image width (x) direction. The unit is specified byPropertyTagResolutionUnit.
YResolutionNumber of pixels per unit in the image height (y) direction. The unit is specified byPropertyTagResolutionUnit.
**The primary source of information to write this class was MSDN.
MSDN Home > MSDN Library > Graphics and Multimedia > GDI+ > GDI+ Reference > Constants
No comments:
Post a Comment