Image::PropertyItems Property
Gets all the property items (pieces of metadata) stored in this Image.
Assembly: System.Drawing (in System.Drawing.dll)
[BrowsableAttribute(false)] public: property array<PropertyItem^>^ PropertyItems { array<PropertyItem^>^ get (); }
Property Value
Type: array<System.Drawing.Imaging::PropertyItem>An array of PropertyItem objects, one for each property item stored in the image.
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 ) { try { // Create an Image object. Image^ theImage = gcnew Bitmap( "c:\\fakePhoto.jpg" ); // Get the PropertyItems property from image. array<PropertyItem^>^propItems = theImage->PropertyItems; // Set up the display. System::Drawing::Font^ font1 = gcnew System::Drawing::Font( "Arial",10 ); SolidBrush^ blackBrush = gcnew SolidBrush( Color::Black ); int X = 0; int Y = 0; // For each PropertyItem in the array, display the id, // type, and length. int count = 0; System::Collections::IEnumerator^ myEnum = propItems->GetEnumerator(); while ( myEnum->MoveNext() ) { PropertyItem^ propItem = safe_cast<PropertyItem^>(myEnum->Current); e->Graphics->DrawString( String::Format( "Property Item {0}", count ), font1, blackBrush, (float)X, (float)Y ); Y += font1->Height; e->Graphics->DrawString( String::Format( " ID: 0x{0}", propItem->Id.ToString( "x" ) ), font1, blackBrush, (float)X, (float)Y ); Y += font1->Height; e->Graphics->DrawString( String::Format( " type: {0}", propItem->Type ), font1, blackBrush, (float)X, (float)Y ); Y += font1->Height; e->Graphics->DrawString( String::Format( " length: {0} bytes", propItem->Len ), font1, blackBrush, (float)X, (float)Y ); Y += font1->Height; count += 1; } delete font1; } catch ( Exception^ ) { 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.