This documentation is archived and is not being maintained.

Image.PropertyItems Property

Gets all the property items (pieces of metadata) stored in this Image.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

public PropertyItem[] PropertyItems { get; }

Property Value

Type: System.Drawing.Imaging.PropertyItem[]
An array of PropertyItem objects, one for each property item stored in the image.

If the image has no property items or if the image format does not support property items, PropertyItems returns an empty array (that is, an array of length zero).

The following code example demonstrates how to read and display the metadata in an image file using the System.Drawing.Imaging.PropertyItem class and the PropertyItems property.

This example is designed to be used 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 void ExtractMetaData(PaintEventArgs e)
        // Create an Image object. 
        Image theImage = new Bitmap("c:\\fakePhoto.jpg");

        // Get the PropertyItems property from image.
        PropertyItem[] propItems = theImage.PropertyItems;

        // Set up the display.
        Font font1 = new Font("Arial", 10);
        SolidBrush blackBrush = new SolidBrush(Color.Black);
        int X = 0;
        int Y = 0;

        // For each PropertyItem in the array, display the id,  
        // type, and length. 
        int count = 0;
        foreach ( PropertyItem propItem in propItems )
            e.Graphics.DrawString("Property Item " + 
                count.ToString(), font1, blackBrush, X, Y);
            Y += font1.Height;

            e.Graphics.DrawString("   ID: 0x" + 
                propItem.Id.ToString("x"), font1, blackBrush, X, Y);
            Y += font1.Height;

            e.Graphics.DrawString("   type: " +
                propItem.Type.ToString(), font1, blackBrush, X, Y);
            Y += font1.Height;

            e.Graphics.DrawString("   length: " + 
                propItem.Len.ToString() + 
                " bytes", font1, blackBrush, X, Y);
            Y += font1.Height;
            count += 1;
        MessageBox.Show("There was an error." + 
            "Make sure the path to the image file is valid.");


Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0