Add or Remove Custom XMP Metadata from GIF using Java

The Extensible Metadata Platform (XMP) data model can be used to store any set of metadata properties in the form of name/value pair encoded as XML-formatted text. As a Java developer, you can easily 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 Java.

The following topics are discussed/covered in this article:

Java API to Add or Remove Custom XMP Metadata

For adding or removing the custom XMP metadata package from GIF images, we will be using GroupDocs.Metadata for Java API. It allows you to add, edit, retrieve, and remove metadata properties from the supported documents and image file formats. The API works with the most notable metadata standards such as built-in metadata properties e.g., author, created date, format-specific metadata properties e.g., XMP, EXIF, IPTC, Image Resource Blocks, ID3, and custom metadata properties.

You can download the JAR of the API or just add the following pom.xml configuration in your Maven-based Java application to try the below-mentioned code examples.

<repository>
	<id>GroupDocsJavaAPI</id>
	<name>GroupDocs Java API</name>
	<url>http://repository.groupdocs.com/repo/</url>
</repository>
<dependency>
        <groupId>com.groupdocs</groupId>
        <artifactId>groupdocs-metadata</artifactId>
        <version>21.8</version> 
</dependency>

Add Custom XMP Metadata Package to GIF using Java

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

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

The above code sample shall add the XMP metadata package to the input image. Please find below the output generated by the ExifTool.

Add Custom XMP Metadata Package to GIF using Java

Add Custom XMP Metadata Package to GIF using Java

Read Custom XMP Package Metadata Properties using Java

You can read all the user-defined properties of the custom XMP package by following the steps given below:

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

The above code sample shall produce the following output:

https://groupdocs.com
gd
gd:Copyright: Copyright (C) 2021 GroupDocs. All Rights Reserved.
gd:CreationDate: Sat Oct 16 00:13:15 PKT 2021
gd:Company: <rdf:Seq><rdf:li>Aspose</rdf:li><rdf:li>GroupDocs</rdf:li></rdf:Seq>

Remove Custom XMP Package using Java

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

The following code sample shows how to remove the XMP metadata package from a GIF image using Java.

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

Remove Custom XMP Package using Java.

Remove Custom XMP Package using Java.

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 custom XMP package metadata to GIF images using Java. Moreover, you have seen how to read XMP package properties and remove them from a GIF image programmatically. You can learn more about GroupDocs.Metadata for Java API using the documentation. In case of any ambiguity, please feel free to contact us on the forum.

See Also