本文整理汇总了Java中com.adobe.xmp.XMPMetaFactory类的典型用法代码示例。如果您正苦于以下问题:Java XMPMetaFactory类的具体用法?Java XMPMetaFactory怎么用?Java XMPMetaFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XMPMetaFactory类属于com.adobe.xmp包,在下文中一共展示了XMPMetaFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: write
import com.adobe.xmp.XMPMetaFactory; //导入依赖的package包/类
/**
* Serializes the XmpDirectory component of <code>Metadata</code> into an <code>OutputStream</code>
* @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;
}
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:25,代码来源:XmpWriter.java
示例2: extract
import com.adobe.xmp.XMPMetaFactory; //导入依赖的package包/类
/**
* Performs the XMP data extraction, adding found values to the specified instance of {@link Metadata}.
* <p>
* The extraction is done with Adobe's XMPCore library.
*/
public void extract(@NotNull final byte[] xmpBytes, int offset, int length, @NotNull Metadata metadata, @Nullable Directory parentDirectory)
{
XmpDirectory directory = new XmpDirectory();
if (parentDirectory != null)
directory.setParent(parentDirectory);
try {
XMPMeta xmpMeta;
// If all xmpBytes are requested, no need to make a new ByteBuffer
if (offset == 0 && length == xmpBytes.length) {
xmpMeta = XMPMetaFactory.parseFromBuffer(xmpBytes);
} else {
ByteBuffer buffer = new ByteBuffer(xmpBytes, offset, length);
xmpMeta = XMPMetaFactory.parse(buffer.getByteStream());
}
directory.setXMPMeta(xmpMeta);
} catch (XMPException e) {
directory.addError("Error processing XMP data: " + e.getMessage());
}
if (!directory.isEmpty())
metadata.addDirectory(directory);
}
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:32,代码来源:XmpReader.java
示例3: extractXMPMeta
import com.adobe.xmp.XMPMetaFactory; //导入依赖的package包/类
/**
* Extracts XMPMeta from a JPEG image file stream.
*
* @param is the input stream containing the JPEG image file.
* @return Extracted XMPMeta or null.
*/
public static XMPMeta extractXMPMeta(InputStream is) {
List<Section> sections = parse(is, true);
if (sections == null) {
return null;
}
// Now we don't support extended xmp.
for (Section section : sections) {
if (hasXMPHeader(section.data)) {
int end = getXMPContentEnd(section.data);
byte[] buffer = new byte[end - XMP_HEADER_SIZE];
System.arraycopy(
section.data, XMP_HEADER_SIZE, buffer, 0, buffer.length);
try {
XMPMeta result = XMPMetaFactory.parseFromBuffer(buffer);
return result;
} catch (XMPException e) {
Log.d(TAG, "XMP parse error", e);
return null;
}
}
}
return null;
}
开发者ID:jameliu,项目名称:Camera2,代码行数:30,代码来源:XmpUtil.java
示例4: XmpHandler
import com.adobe.xmp.XMPMetaFactory; //导入依赖的package包/类
/**
* Create an XmpHandler from an XMP String.
*
* @param xmpString
* the XMP String.
*/
public XmpHandler(final String xmpString) {
prepareRegistry();
if (xmpString == null) {
Logger.warning("xmpString is null");
mXmpMeta = XMPMetaFactory.create();
return;
}
try {
String updatedXmpString = xmpString.trim();
int i = updatedXmpString.lastIndexOf('<');
if (i > 0 && updatedXmpString.substring(i).startsWith("<?xpacket end")) {
updatedXmpString = updatedXmpString.substring(0, i);
}
mXmpMeta = XMPMetaFactory.parseFromString(updatedXmpString);
}
catch (Exception e) {
Logger.warning("Error when parsing XMP Data: " + e.toString());
mXmpMeta = XMPMetaFactory.create();
}
}
开发者ID:jeisfeld,项目名称:Augendiagnose,代码行数:29,代码来源:XmpHandler.java
示例5: prepareRegistry
import com.adobe.xmp.XMPMetaFactory; //导入依赖的package包/类
/**
* Add namespaces to the registry.
*/
private static void prepareRegistry() {
if (!mIsPrepared) {
XMPSchemaRegistry registry = XMPMetaFactory.getSchemaRegistry();
try {
registry.registerNamespace(NS_JE, "je:");
registry.registerNamespace(NS_MP1, "MicrosoftPhoto:");
registry.registerNamespace(NS_MP2, "MP:");
registry.registerNamespace(NS_MPRI, "MPRI:");
registry.registerNamespace(NS_MPREG, "MPReg:");
registry.registerNamespace(NS_DC, "dc:");
registry.registerNamespace(NS_EXIF, "exif:");
mIsPrepared = true;
}
catch (XMPException e) {
Logger.error("Exception while preparing XMP registry", e);
}
}
}
开发者ID:jeisfeld,项目名称:Augendiagnose,代码行数:22,代码来源:XmpHandler.java
示例6: XmpHandler
import com.adobe.xmp.XMPMetaFactory; //导入依赖的package包/类
/**
* Create an XmpHandler from an XMP String.
*
* @param xmpString the XMP String.
*/
public XmpHandler(@Nullable final String xmpString) {
prepareRegistry();
if (xmpString == null) {
Log.w(Application.TAG, "xmpString is null ");
mXmpMeta = XMPMetaFactory.create();
return;
}
try {
String updatedXmpString = xmpString.trim();
int i = updatedXmpString.lastIndexOf('<');
if (i > 0 && updatedXmpString.substring(i).startsWith("<?xpacket end")) {
updatedXmpString = updatedXmpString.substring(0, i);
}
mXmpMeta = XMPMetaFactory.parseFromString(updatedXmpString);
}
catch (Exception e) {
Log.w(Application.TAG, "Error when parsing XMP Data ", e);
mXmpMeta = XMPMetaFactory.create();
}
}
开发者ID:jeisfeld,项目名称:Augendiagnose,代码行数:28,代码来源:XmpHandler.java
示例7: prepareRegistry
import com.adobe.xmp.XMPMetaFactory; //导入依赖的package包/类
/**
* Add namespaces to the registry.
*/
private static void prepareRegistry() {
if (!mIsPrepared) {
XMPSchemaRegistry registry = XMPMetaFactory.getSchemaRegistry();
try {
registry.registerNamespace(NS_JE, "je:");
registry.registerNamespace(NS_MP1, "MicrosoftPhoto:");
registry.registerNamespace(NS_MP2, "MP:");
registry.registerNamespace(NS_MPRI, "MPRI:");
registry.registerNamespace(NS_MPREG, "MPReg:");
registry.registerNamespace(NS_DC, "dc:");
registry.registerNamespace(NS_EXIF, "exif:");
mIsPrepared = true;
}
catch (XMPException e) {
Log.e(Application.TAG, "Exception while preparing XMP registry", e);
}
}
}
开发者ID:jeisfeld,项目名称:Augendiagnose,代码行数:22,代码来源:XmpHandler.java
示例8: extract
import com.adobe.xmp.XMPMetaFactory; //导入依赖的package包/类
/**
* Performs the XMP data extraction, adding found values to the specified instance of {@link Metadata}.
* <p/>
* The extraction is done with Adobe's XMPCore library.
*/
public void extract(@NotNull final String xmpString, @NotNull Metadata metadata)
{
XmpDirectory directory = metadata.getOrCreateDirectory(XmpDirectory.class);
try {
XMPMeta xmpMeta = XMPMetaFactory.parseFromString(xmpString);
processXmpTags(directory, xmpMeta);
} catch (XMPException e) {
directory.addError("Error processing XMP data: " + e.getMessage());
}
}
开发者ID:byronb92,项目名称:ImageEXIFExtraction,代码行数:17,代码来源:XmpReader.java
示例9: createXmpMetadata
import com.adobe.xmp.XMPMetaFactory; //导入依赖的package包/类
byte[] createXmpMetadata()
{
try
{
XMPMeta xmp = XMPMetaFactory.create();
xmp.setObjectName("");
xmp.setProperty(XMPConst.NS_DC, DublinCoreSchema.FORMAT, FORMAT_PDF);
xmp.setProperty(XMPConst.NS_PDF, PDF_PRODUCER, Document.getVersion());
if (pdfWriter.getPDFXConformance() == PdfWriter.PDFA1A)
{
xmp.setProperty(XMPConst.NS_PDFA_ID, PDFA_PART, PDFA_PART_1);
xmp.setProperty(XMPConst.NS_PDFA_ID, PDFA_CONFORMANCE, PDFA_CONFORMANCE_A);
}
else if (pdfWriter.getPDFXConformance() == PdfWriter.PDFA1B)
{
xmp.setProperty(XMPConst.NS_PDFA_ID, PDFA_PART, PDFA_PART_1);
xmp.setProperty(XMPConst.NS_PDFA_ID, PDFA_CONFORMANCE, PDFA_CONFORMANCE_B);
}
xmp.setProperty(XMPConst.NS_XMP, XMP_CREATE_DATE, ((PdfDate) info.get(PdfName.CREATIONDATE)).getW3CDate());
xmp.setProperty(XMPConst.NS_XMP, XMP_MODIFY_DATE, ((PdfDate) info.get(PdfName.MODDATE)).getW3CDate());
String title = extractInfo(PdfName.TITLE);
if (title != null)
{
xmp.setLocalizedText(XMPConst.NS_DC, DublinCoreSchema.TITLE,
//FIXME use the tag language?
XMPConst.X_DEFAULT, XMPConst.X_DEFAULT, title);
}
String author = extractInfo(PdfName.AUTHOR);
if (author != null)
{
//FIXME cache the options?
PropertyOptions arrayOrdered = new PropertyOptions().setArrayOrdered(true);
xmp.appendArrayItem(XMPConst.NS_DC, DublinCoreSchema.CREATOR, arrayOrdered, author, null);
}
String subject = extractInfo(PdfName.SUBJECT);
if (subject != null)
{
PropertyOptions array = new PropertyOptions().setArray(true);
xmp.appendArrayItem(XMPConst.NS_DC, DublinCoreSchema.SUBJECT, array, subject, null);
xmp.setLocalizedText(XMPConst.NS_DC, DublinCoreSchema.DESCRIPTION,
XMPConst.X_DEFAULT, XMPConst.X_DEFAULT, subject);
}
String keywords = extractInfo(PdfName.KEYWORDS);
if (keywords != null)
{
xmp.setProperty(XMPConst.NS_PDF, PDF_KEYWORDS, keywords);
}
String creator = extractInfo(PdfName.CREATOR);
if (creator != null)
{
xmp.setProperty(XMPConst.NS_XMP, XMP_CREATOR_TOOL, creator);
}
SerializeOptions options = new SerializeOptions();
options.setUseCanonicalFormat(true);
ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
XMPMetaFactory.serialize(xmp, out, options);
return out.toByteArray();
}
catch (XMPException e)
{
throw new JRRuntimeException(e);
}
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:74,代码来源:PdfXmpCreator.java
示例10: extract
import com.adobe.xmp.XMPMetaFactory; //导入依赖的package包/类
/**
* Performs the XMP data extraction, adding found values to the specified instance of {@link Metadata}.
* <p/>
* The extraction is done with Adobe's XMPCore library.
*/
public void extract(@NotNull final byte[] xmpBytes, @NotNull Metadata metadata)
{
XmpDirectory directory = metadata.getOrCreateDirectory(XmpDirectory.class);
try {
XMPMeta xmpMeta = XMPMetaFactory.parseFromBuffer(xmpBytes);
processXmpTags(directory, xmpMeta);
} catch (XMPException e) {
directory.addError("Error processing XMP data: " + e.getMessage());
}
}
开发者ID:ydanila,项目名称:j-metadata-extractor,代码行数:17,代码来源:XmpReader.java
示例11: read
import com.adobe.xmp.XMPMetaFactory; //导入依赖的package包/类
public static ZfMetaData read(InputStream in) {
try {
XMPMeta element = XMPMetaFactory.parse(in);
XMPIterator iterator = element.iterator();
return parseZfData(iterator);
}
catch (XMPException e) {
throw new RuntimeException(e);
}
}
开发者ID:opendatalab-de,项目名称:zugferd,代码行数:11,代码来源:ZfMetaDataReader.java
示例12: createXMPMeta
import com.adobe.xmp.XMPMetaFactory; //导入依赖的package包/类
/**
* Creates a new XMPMeta.
*/
public static XMPMeta createXMPMeta() {
return XMPMetaFactory.create();
}
开发者ID:jameliu,项目名称:Camera2,代码行数:7,代码来源:XmpUtil.java
示例13: insertXMPSection
import com.adobe.xmp.XMPMetaFactory; //导入依赖的package包/类
private static List<Section> insertXMPSection(
List<Section> sections, XMPMeta meta) {
if (sections == null || sections.size() <= 1) {
return null;
}
byte[] buffer;
try {
SerializeOptions options = new SerializeOptions();
options.setUseCompactFormat(true);
// We have to omit packet wrapper here because
// javax.xml.parsers.DocumentBuilder
// fails to parse the packet end <?xpacket end="w"?> in android.
options.setOmitPacketWrapper(true);
buffer = XMPMetaFactory.serializeToBuffer(meta, options);
} catch (XMPException e) {
Log.d(TAG, "Serialize xmp failed", e);
return null;
}
if (buffer.length > MAX_XMP_BUFFER_SIZE) {
// Do not support extended xmp now.
return null;
}
// The XMP section starts with XMP_HEADER and then the real xmp data.
byte[] xmpdata = new byte[buffer.length + XMP_HEADER_SIZE];
System.arraycopy(XMP_HEADER.getBytes(), 0, xmpdata, 0, XMP_HEADER_SIZE);
System.arraycopy(buffer, 0, xmpdata, XMP_HEADER_SIZE, buffer.length);
Section xmpSection = new Section();
xmpSection.marker = M_APP1;
// Adds the length place (2 bytes) to the section length.
xmpSection.length = xmpdata.length + 2;
xmpSection.data = xmpdata;
for (int i = 0; i < sections.size(); ++i) {
// If we can find the old xmp section, replace it with the new one.
if (sections.get(i).marker == M_APP1
&& hasXMPHeader(sections.get(i).data)) {
// Replace with the new xmp data.
sections.set(i, xmpSection);
return sections;
}
}
// If the first section is Exif, insert XMP data before the second section,
// otherwise, make xmp data the first section.
List<Section> newSections = new ArrayList<Section>();
int position = (sections.get(0).marker == M_APP1) ? 1 : 0;
newSections.addAll(sections.subList(0, position));
newSections.add(xmpSection);
newSections.addAll(sections.subList(position, sections.size()));
return newSections;
}
开发者ID:jameliu,项目名称:Camera2,代码行数:51,代码来源:XmpUtil.java
示例14: getXmpString
import com.adobe.xmp.XMPMetaFactory; //导入依赖的package包/类
/**
* Get the XMP String.
*
* @return the XMP String.
* @throws XMPException
* thrown in case of issues with XML handling.
*/
public final String getXmpString() throws XMPException {
return XMPMetaFactory.serializeToString(mXmpMeta, null);
}
开发者ID:jeisfeld,项目名称:Augendiagnose,代码行数:11,代码来源:XmpHandler.java
示例15: getXmpString
import com.adobe.xmp.XMPMetaFactory; //导入依赖的package包/类
/**
* Get the XMP String.
*
* @return the XMP String.
* @throws XMPException thrown in case of issues with XMP handling.
*/
public final String getXmpString() throws XMPException {
return XMPMetaFactory.serializeToString(mXmpMeta, null);
}
开发者ID:jeisfeld,项目名称:Augendiagnose,代码行数:10,代码来源:XmpHandler.java
注:本文中的com.adobe.xmp.XMPMetaFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论