--- title: "How to: Read Image Metadata" desription: Learn how to read the Windows Forms PropertyItems property of an Image object to retrieve all the metadata from a file. ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "metadata [Windows Forms], property item" - "metadata [Windows Forms], reading image" ms.assetid: 72ec0b31-0be7-444a-9575-1dbcb864e0be --- # How to: Read Image Metadata Some image files contain metadata that you can read to determine features of the image. For example, a digital photograph might contain metadata that you can read to determine the make and model of the camera used to capture the image. With GDI+, you can read existing metadata, and you can also write new metadata to image files. GDI+ stores an individual piece of metadata in a object. You can read the property of an object to retrieve all the metadata from a file. The property returns an array of objects. A object has the following four properties: `Id`, `Value`, `Len`, and `Type`. ## Id A tag that identifies the metadata item. Some values that can be assigned to are shown in the following table: |Hexadecimal value|Description| |-----------------------|-----------------| |0x0320

0x010F

0x0110

0x9003

0x829A

0x5090

0x5091|Image title

Equipment manufacturer

Equipment model

ExifDTOriginal

Exif exposure time

Luminance table

Chrominance table| ## Value An array of values. The format of the values is determined by the property. ## Len The length (in bytes) of the array of values pointed to by the property. ## Type The data type of the values in the array pointed to by the `Value` property. The formats indicated by the `Type` property values are shown in the following table: |Numeric value|Description| |-------------------|-----------------| |1|A `Byte`| |2|An array of `Byte` objects encoded as ASCII| |3|A 16-bit integer| |4|A 32-bit integer| |5|An array of two `Byte` objects that represent a rational number| |6|Not used| |7|Undefined| |8|Not used| |9|`SLong`| |10|`SRational`| ## Example The following code example reads and displays the seven pieces of metadata in the file `FakePhoto.jpg`. The second (index 1) property item in the list has 0x010F (equipment manufacturer) and 2 (ASCII-encoded byte array). The code example displays the value of that property item. [!code-csharp[System.Drawing.WorkingWithImages#51](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Drawing.WorkingWithImages/CS/Class1.cs#51)] [!code-vb[System.Drawing.WorkingWithImages#51](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Drawing.WorkingWithImages/VB/Class1.vb#51)] The code produces output similar to the following: ```output Property Item 0 id: 0x320 type: 2 length: 16 bytes Property Item 1 id: 0x10f type: 2 length: 17 bytes Property Item 2 id: 0x110 type: 2 length: 7 bytes Property Item 3 id: 0x9003 type: 2 length: 20 bytes Property Item 4 id: 0x829a type: 5 length: 8 bytes Property Item 5 id: 0x5090 type: 3 length: 128 bytes Property Item 6 id: 0x5091 type: 3 length: 128 bytes The equipment make is Northwind Camera. ``` ## Compiling the Code The preceding example is designed for use with Windows Forms, and it requires `e`, which is a parameter of the event handler. Handle the form's event and paste this code into the paint event handler. You must replace `FakePhoto.jpg` with an image name and path valid on your system and import the `System.Drawing.Imaging` namespace. ## See also - [Images, Bitmaps, and Metafiles](images-bitmaps-and-metafiles.md) - [Working with Images, Bitmaps, Icons, and Metafiles](working-with-images-bitmaps-icons-and-metafiles.md)