Last updated on May 5, 2021 by Muzammil Khan
Blog Home

Add or Remove Custom XMP Metadata from GIF using C#

Share on Facebook
Facebook
Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin
Add or Remove Custom XMP Metadata from GIF using C#

The Extensible Metadata Platform (XMP) metadata is encoded as XML-formatted text. The defined XMP data model can be used to store any set of metadata properties in the form of name/value pair. You can add a custom XMP metadata package to your images programmatically. In this article, you will learn how to add or remove custom XMP metadata from GIF using C#.

The following topics are discussed/covered in this article:

  • C# API for Adding or Removing XMP Metadata
  • Add Custom XMP Metadata Package to GIF using C#
  • Read Custom XMP Metadata Package Properties using C#
  • Remove Custom XMP Metadata Package using C#

C# API for Adding or Removing XMP Metadata

I will be using GroupDocs.Metadata for .NET API for adding or removing custom XMP metadata package. It allows you to add, edit, retrieve, and remove metadata properties from documents and image file formats. The API works with the most notable metadata standards such as built-in, XMP, EXIF, IPTC, Image Resource Blocks, ID3, and custom metadata properties. It can be used to develop applications in any development environment that targets the .NET platform.

You can either download the DLL of the API or install it using the NuGet.

Install-Package GroupDocs.Metadata

Add Custom XMP Metadata Package to GIF using C#

You can easily create and add a fully custom XMP package containing user-defined properties by following the simple steps mentioned below:

  • Create an instance of the Metadata class
  • Provide path of the GIF image
  • GetRootPackage as IXmp standard
  • Create an instance of XmpPackage class
  • Provide package Prefix and NamespaceUri
  • Set properties in Name/ Value pair using Set method
  • Create an instance of XmpPacketWrapper class
  • Call the AddPackage method and pass created XmpPackage
  • Assign created XmpPacketWrapper to IXMp.XmpPackage
  • Save the output file using the Metadata.Save method

The following code sample shows how to create and add a custom XMP metadata package to GIF image using C#.

The above code sample shall add the XMP metadata package to input image. The ExifTool read the following metadata from the generated output GIF image.

Add XMP Metadata Package to GIF using C#
Add XMP Metadata Package to GIF using C#

The IXMP interface exposes XmpPackage property to gets or set the XMP metadata package.

The Metadata class provides GetRootPackage method to get the root package that provides access to all metadata properties extracted from the file.

The XmpPackage class provides various properties to define the package such as Prefix, NamespaceUri, and Keys. This class also provides Set methods to set name/ value for user defined metadata properties.

The XmpPacketWrapper class contains serialized XMP package. The AddPackage method of this class allows to add the defined custom package.

You can find more details about “Working with XMP Metadata” in the documentation.

Read Custom XMP Package Metadata Properties using C#

You can easily read all the custom XMP package user-defined properties by following the simple steps mentioned below:

  • Create an instance of the Metadata class
  • Provide the path of the GIF image
  • GetRootPackage as IXmp standard
  • Get all packages one by one from IXmp.XmpPackage.Packages
  • Get NamespaceUri and Prefix for each package
  • Call FindProperties for each package Key to get property name and value

The following code sample shows how to read all the properties defined in the custom XMP package using C#.

The above code sample shall produce the following output:

https://groupdocs.com
gd
gd:Copyright : Copyright (C) 2021 GroupDocs. All Rights Reserved.
gd:CreationDate : 04/05/2021 2:26:17 am
gd:Company : <rdf:Seq><rdf:li>Aspose</rdf:li><rdf:li>GroupDocs</rdf:li></rdf:Seq>

The FindProperties method of the XmpPackage class recursively searches and finds the metadata properties satisfying the specified predicate.

Remove Custom XMP Package using C#

You can remove XMP package from GIF images by following the simple steps mentioned below:

  • Create an instance of the Metadata class
  • Provide the path of the GIF image
  • GetRootPackage as IXmp standard
  • Set IXMp.XmpPackage to null
  • Save the output file using the Metadata.Save method

The following code sample shows how to remove XMP metadata package from GIF image using C#.

The above code sample shall remove the XMP metadata package from input image. The ExifTool read the following metadata from the generated output GIF image.

Remove XMP Metadata Package from GIF using C#
Remove XMP Metadata Package from GIF using C#

Get a Free License

You can try the API without evaluation limitations by requesting a free temporary license.

Conclusion

In this article, you have learned how to add or remove custom XMP package metadata from GIF images using C#. You also learned how to read XMP package properties using C#. Moreover, you can learn about GroupDocs.Metadata for .NET API using the documentation. In case of any ambiguity, please feel free to contact us on the forum.

See Also

  • Extract and Manipulate Metadata of Images using C#
  • Manage EXIF Data of JPEG, PNG, TIFF & WebP Images in C#

No related posts.


This entry was posted in Conholdate.Total Product Family and tagged Add Custom XMP Metadata C#, Custom XMP Metadata to GIF, Read Custom XMP Metadata C#, Remove Custom XMP Metadata C#. .

← Generate Reports from Excel Data in C#
Search for a Word in PDF using Java →
  • Follow Us

    RSS Facebook Twitter YouTube LinkedIn

  • Categories

    • Conholdate.Total Product Family
      (62)
  • Archives

    • February 2022 (5)
    • January 2022 (4)
    • December 2021 (5)
    • November 2021 (3)
    • October 2021 (8)
    • September 2021 (5)
    • August 2021 (4)
    • July 2021 (4)
    • June 2021 (3)
    • May 2021 (4)
    • April 2021 (7)
    • March 2021 (1)
    • January 2021 (2)
    • December 2020 (3)
    • August 2020 (1)
    • July 2020 (1)
    • June 2020 (2)
    • January 2020 (1)
    • December 2019 (1)