How do I access / edit the metadata associated with an Image ?

Platform: WPF|Category: Image

The ‘BitmapMetaData’ class provides metadata information contained by the image. This metadata can be one metadata schema or a combination of different schemes.

WPF inherently supports the following image schemas:

  • ExchangableImageFile (Exif).

  • PNG Textual Data.

  • ImageFileDirectory (IFD).

  • InternationalPressTelecommunicationsCouncil (IPTC).

  • ExtensibleMarkupLanguage (XMP).

[C#]

            Stream pngStream = new System.IO.FileStream('winter.png', FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
            PngBitmapDecoder pngDecoder = new PngBitmapDecoder(pngStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
            BitmapFrame pngFrame = pngDecoder.Frames[0];
            InPlaceBitmapMetadataWriter pngInplace = pngFrame.CreateInPlaceBitmapMetadataWriter();
            if (pngInplace.TrySave() == true)
            { 
	pngInplace.SetQuery('/Text/Author', 'Me'); 
            }
            pngStream.Close();