The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ImageItemData class

Applies to: desktop apps only

The ImageItemData class is used to store and retrieve custom image metadata. Windows GDI+ supports custom metadata for JPEG, PNG, and GIF image files.

ImageItemData has these types of members:

Data Members

The following table lists the members exposed by the ImageItemData object.

Data MembersTypeDescription
SizeUINTInteger that specifies the size of an ImageItemData object. Set to sizeof(ImageItemData).
PositionUINTElement of the ItemDataPosition enumeration that specifies the location in an image file that a piece of custom metadata should be stored.
DescVOID *A sequence of bytes that you create to identify a piece of custom metadata. For JPEG files, the description is one byte. For PNG files, the description is four bytes. For GIF files, the description is eleven bytes.
DescSizeUINTInteger that specifies the size, in bytes, of the identifier pointed to by Desc. Set to 1 for JPEG, 4 for PNG, and 11 for GIF.
DataUINT *Pointer to a buffer that contains the metadata.
DataSizeUINTInteger that specifies the size, in bytes, of the buffer pointed to by Data.
CookieUINTUsed internally by GDI+.



To retrieve custom metadata from an image file, call Image::GetItemData. To store custom metadata in an image file, follow these steps:

  1. Create and initialize an ImageItemData object.
  2. Create an EncoderParameters object that has an array of one or more EncoderParameter objects.
  3. For one of the EncoderParameter objects in the array, set the Value member to the address of your ImageItemData object. Set the other members as follows: Guid = EncoderImageItems, Type = EncoderParameterValueTypePointer, NumberOfValues = 1.
  4. Pass the address of the EncoderParameters object to the Image::Save method of an Image object.


The following example saves a piece of custom metadata in a JPEG file. The code relies on a helper function, GetEncoderClsid, to get the class identifier for the JPEG encoder. To see the source code for GetEncoderClsid, see Retrieving the Class Identifier for an Encoder.

CHAR myData[] = "Byte sequence of your choice";
BYTE description = 0xE4;

ImageItemData itemData;
itemData.Size = sizeof(itemData);
itemData.DescSize = 1;
itemData.Desc = &description;
itemData.DataSize = 28;
itemData.Data = (VOID*)myData;
itemData.Position = ItemDataPositionAfterHeader;

// Get the Clsid of the JPEG encoder.
CLSID encoderClsid;
GetEncoderClsid(L"image/jpeg", &encoderClsid);

EncoderParameters encoderParameters;
encoderParameters.Count = 1;
encoderParameters.Parameter[0].Guid = EncoderImageItems;
encoderParameters.Parameter[0].Type = EncoderParameterValueTypePointer;
encoderParameters.Parameter[0].NumberOfValues = 1; 
encoderParameters.Parameter[0].Value = &itemData;

Image image(L"River.jpg");
image.Save(L"River2.jpg", &encoderClsid, &encoderParameters);


Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008


GDI+ 1.1


Gdiplusimaging.h (include Gdiplus.h)





Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions