All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.drew.metadata.xmp.XmpWriter Maven / Gradle / Ivy

Go to download

Java library for extracting EXIF, IPTC, XMP, ICC and other metadata from image and video files.

There is a newer version: 2.19.0
Show newest version
package com.drew.metadata.xmp;

import java.io.OutputStream;

import com.adobe.xmp.XMPException;
import com.adobe.xmp.XMPMeta;
import com.adobe.xmp.XMPMetaFactory;
import com.adobe.xmp.options.SerializeOptions;
import com.drew.metadata.Metadata;

public class XmpWriter
{
    /**
     * Serializes the XmpDirectory component of Metadata into an OutputStream
     * @param os Destination for the xmp data
     * @param data populated metadata
     * @return serialize success
     */
    public static boolean write(OutputStream os, Metadata data)
    {
        XmpDirectory dir = data.getFirstDirectoryOfType(XmpDirectory.class);
        if (dir == null)
            return false;
        XMPMeta meta = dir.getXMPMeta();
        try
        {
            SerializeOptions so = new SerializeOptions().setOmitPacketWrapper(true);
            XMPMetaFactory.serialize(meta, os, so);
        }
        catch (XMPException e)
        {
            e.printStackTrace();
            return false;
        }
        return true;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy