Working with metadata in PNG images
Leave feedback
The GroupDocs.Metadata API supports extracting format-specific information from PNG images.
The following are the steps to read the native PNG metadata.
- Load a PNG image
- Get the root metadata package
- Extract the native metadata package using PngRootPackage.getPngPackage
- Read the PNG metadata properties
advanced_usage.managing_metadata_for_specific_formats.
try (Metadata metadata = new Metadata(Constants.InputPng)) {
PngRootPackage root = metadata.getRootPackageGeneric();
for (PngTextChunk chunk : root.getPngPackage().getTextChunks()) {
System.out.println(chunk.getKeyword());
System.out.println(chunk.getText());
if (chunk instanceof PngCompressedTextChunk) {
PngCompressedTextChunk compressedChunk = (PngCompressedTextChunk) chunk;
System.out.println(compressedChunk.getCompressionMethod());
}
if (chunk instanceof PngInternationalTextChunk) {
PngInternationalTextChunk internationalChunk = (PngInternationalTextChunk) chunk;
System.out.println(internationalChunk.isCompressed());
System.out.println(internationalChunk.getLanguage());
System.out.println(internationalChunk.getTranslatedKeyword());
}
}
}
GroupDocs.Metadata for Java allows managing XMP metadata in PNG images. For more details please refer to the following guide: Working with XMP Metadata.
The GroupDocs.Metadata API supports handling EXIF metadata in PNG images. Please find appropriate code samples in the Working with EXIF Metadata section.
You may easily run the code above and see the feature in action in our GitHub examples:
Along with full featured Java library we provide simple, but powerful free Apps.
You are welcome to view and edit metadata of PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, emails, images and more with our free online Free Online Document Metadata Viewing and Editing App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.