Encapsulates a metadata property to be included in an image file. Not inheritable.
Assembly: System.Drawing (in System.Drawing.dll)
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Serves as the default hash function. (Inherited from Object.)
Returns a string that represents the current object.(Inherited from Object.)
The data consists of: an identifier, the length (in bytes) of the property, the property type, and a pointer to the property value.
A Image. A object is used to retrieve and to change the metadata of existing image files, not to create the metadata. Therefore, the class does not have a defined Public constructor, and you cannot create an instance of a object.is not intended to be used as a stand-alone object. A object is intended to be used by classes that are derived from
To work around the absence of a Public constructor, use an existing Image.GetPropertyItem.object instead of creating a new instance of the class. For more information, see
The following code example demonstrates how to read and display the metadata in an image file using the Image.PropertyItems property.class and the
This example is designed to be used in a Windows Form that imports the System.Drawing.Imaging namespace. Paste the code into the form and change the path to fakePhoto.jpg to point to an image file on your system. Call the ExtractMetaData method when handling the form's Paint event, passing e as PaintEventArgs.
Private Sub ExtractMetaData(ByVal e As PaintEventArgs) Try 'Create an Image object. Dim theImage As Image = New Bitmap("c:\fakePhoto.jpg") 'Get the PropertyItems property from image. Dim propItems As PropertyItem() = theImage.PropertyItems 'Set up the display. Dim font As New font("Arial", 10) Dim blackBrush As New SolidBrush(Color.Black) Dim X As Integer = 0 Dim Y As Integer = 0 'For each PropertyItem in the array, display the id, type, and length. Dim count As Integer = 0 Dim propItem As PropertyItem For Each propItem In propItems e.Graphics.DrawString("Property Item " + count.ToString(), _ font, blackBrush, X, Y) Y += font.Height e.Graphics.DrawString(" iD: 0x" & propItem.Id.ToString("x"), _ font, blackBrush, X, Y) Y += font.Height e.Graphics.DrawString(" type: " & propItem.Type.ToString(), _ font, blackBrush, X, Y) Y += font.Height e.Graphics.DrawString(" length: " & propItem.Len.ToString() & _ " bytes", font, blackBrush, X, Y) Y += font.Height count += 1 Next propItem font.Dispose() Catch ex As ArgumentException MessageBox.Show("There was an error. Make sure the path to the image file is valid.") End Try End Sub
Available since 1.1
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.