当前位置: 首页>>代码示例>>Java>>正文


Java XMPException类代码示例

本文整理汇总了Java中com.adobe.xmp.XMPException的典型用法代码示例。如果您正苦于以下问题:Java XMPException类的具体用法?Java XMPException怎么用?Java XMPException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XMPException类属于com.adobe.xmp包,在下文中一共展示了XMPException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: write

import com.adobe.xmp.XMPException; //导入依赖的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.XMPException; //导入依赖的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: getInt

import com.adobe.xmp.XMPException; //导入依赖的package包/类
private static int getInt(XMPMeta xmp, String key) throws XMPException {
    if (xmp.doesPropertyExist(GOOGLE_PANO_NAMESPACE, key)) {
        return xmp.getPropertyInteger(GOOGLE_PANO_NAMESPACE, key);
    } else {
        return 0;
    }
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:8,代码来源:TinyPlanetFragment.java

示例4: extractXMPMeta

import com.adobe.xmp.XMPException; //导入依赖的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

示例5: getXmpProperties

import com.adobe.xmp.XMPException; //导入依赖的package包/类
/**
 * Gets a map of all XMP properties in this directory.
 * <p>
 * This is required because XMP properties are represented as strings, whereas the rest of this library
 * uses integers for keys.
 */
@NotNull
public Map<String, String> getXmpProperties()
{
    Map<String, String> propertyValueByPath = new HashMap<String, String>();

    if (_xmpMeta != null)
    {
        try {
            for (Iterator i = _xmpMeta.iterator(); i.hasNext(); ) {
                XMPPropertyInfo prop = (XMPPropertyInfo)i.next();
                String path = prop.getPath();
                String value = prop.getValue();
                if (path != null && value != null) {
                    propertyValueByPath.put(path, value);
                }
            }
        } catch (XMPException ignored) {
        }
    }

    return Collections.unmodifiableMap(propertyValueByPath);
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:29,代码来源:XmpDirectory.java

示例6: setXMPMeta

import com.adobe.xmp.XMPException; //导入依赖的package包/类
public void setXMPMeta(@NotNull XMPMeta xmpMeta)
{
    _xmpMeta = xmpMeta;

    try {
        int valueCount = 0;
        for (Iterator i = _xmpMeta.iterator(); i.hasNext(); ) {
            XMPPropertyInfo prop = (XMPPropertyInfo)i.next();
            if (prop.getPath() != null) {
                valueCount++;
            }
        }
        setInt(TAG_XMP_VALUE_COUNT, valueCount);
    } catch (XMPException ignored) {
    }
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:17,代码来源:XmpDirectory.java

示例7: prepareRegistry

import com.adobe.xmp.XMPException; //导入依赖的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

示例8: changeMetadata

import com.adobe.xmp.XMPException; //导入依赖的package包/类
/**
 * Change metadata of the image (EXIF and XMP as far as applicable).
 *
 * @param jpegImageFileName the file for which metadata should be changed.
 * @param metadata          the new metadata.
 * @throws ImageReadException  thrown if the metadata cannot be read.
 * @throws ImageWriteException thrown if the metadata cannot be written.
 * @throws IOException         thrown in case of other errors while reading metadata.
 * @throws XMPException        thrown in case of issues with XML handling.
 */
public static void changeMetadata(@NonNull final String jpegImageFileName, @NonNull final JpegMetadata metadata) throws IOException,
		ImageReadException, ImageWriteException, XMPException {
	if (changeJpegAllowed()) {
		checkJpeg(jpegImageFileName);
		changeXmpMetadata(jpegImageFileName, metadata);

		if (changeExifAllowed()) {
			try {
				changeExifMetadata(jpegImageFileName, metadata);
			}
			catch (Exception e) {
				throw new ExifStorageException(e);
			}
		}
	}
}
 
开发者ID:jeisfeld,项目名称:Augendiagnose,代码行数:27,代码来源:JpegMetadataUtil.java

示例9: prepareRegistry

import com.adobe.xmp.XMPException; //导入依赖的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

示例10: extract

import com.adobe.xmp.XMPException; //导入依赖的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

示例11: processXmpDateTag

import com.adobe.xmp.XMPException; //导入依赖的package包/类
@SuppressWarnings({ "SameParameterValue" })
void processXmpDateTag(@NotNull XMPMeta meta, @NotNull XmpDirectory directory, @NotNull String schemaNS, @NotNull String propName, int tagType) throws XMPException
{
    Calendar cal = meta.getPropertyCalendar(schemaNS, propName);

    if (cal == null)
        return;

    directory.setDate(tagType, cal.getTime());
}
 
开发者ID:mxbossard,项目名称:metadata-extractor-osgi,代码行数:11,代码来源:XmpReader.java

示例12: createXmpMetadata

import com.adobe.xmp.XMPException; //导入依赖的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

示例13: getExtendedXMPGUID

import com.adobe.xmp.XMPException; //导入依赖的package包/类
/**
 * Determine if there is an extended XMP section based on the standard XMP part.
 * The xmpNote:HasExtendedXMP attribute contains the GUID of the Extended XMP chunks.
 */
@Nullable
private static String getExtendedXMPGUID(@NotNull Metadata metadata)
{
    final Collection<XmpDirectory> xmpDirectories = metadata.getDirectoriesOfType(XmpDirectory.class);

    for (XmpDirectory directory : xmpDirectories) {
        final XMPMeta xmpMeta = directory.getXMPMeta();

        try {
            final XMPIterator itr = xmpMeta.iterator(SCHEMA_XMP_NOTES, null, null);
            if (itr == null)
                continue;

            while (itr.hasNext()) {
                final XMPPropertyInfo pi = (XMPPropertyInfo) itr.next();
                if (ATTRIBUTE_EXTENDED_XMP.equals(pi.getPath())) {
                    return pi.getValue();
                }
            }
        } catch (XMPException e) {
            // Fail silently here: we had a reading issue, not a decoding issue.
        }
    }

    return null;
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:31,代码来源:XmpReader.java

示例14: xmpSample

import com.adobe.xmp.XMPException; //导入依赖的package包/类
private static void xmpSample(InputStream imageStream) throws XMPException, ImageProcessingException, IOException
{
    // Extract metadata from the image
    Metadata metadata = ImageMetadataReader.readMetadata(imageStream);

    // Iterate through any XMP directories we may have received
    for (XmpDirectory xmpDirectory : metadata.getDirectoriesOfType(XmpDirectory.class)) {

        // Usually with metadata-extractor, you iterate a directory's tags. However XMP has
        // a complex structure with many potentially unknown properties. This doesn't map
        // well to metadata-extractor's directory-and-tag model.
        //
        // If you need to use XMP data, access the XMPMeta object directly.
        XMPMeta xmpMeta = xmpDirectory.getXMPMeta();

        XMPIterator itr = xmpMeta.iterator();

        // Iterate XMP properties
        while (itr.hasNext()) {

            XMPPropertyInfo property = (XMPPropertyInfo) itr.next();

            // Print details of the property
            System.out.println(property.getPath() + ": " + property.getValue());
        }
    }
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:28,代码来源:XmpSample.java

示例15: setDcItem

import com.adobe.xmp.XMPException; //导入依赖的package包/类
/**
 * Set an entry in the DC namespace.
 *
 * @param item
 *            the name of the entry.
 * @param value
 *            the value of the entry.
 * @throws XMPException
 *             thrown in case of issues with XML handling.
 */
private void setDcItem(final String item, final String value) throws XMPException {
	if (value != null) {
		if (mXmpMeta.doesArrayItemExist(NS_DC, item, 1)) {
			mXmpMeta.setArrayItem(NS_DC, item, 1, value);
		}
		else {
			mXmpMeta.appendArrayItem(NS_DC, item, new PropertyOptions().setArray(true), value, null);
		}
	}
}
 
开发者ID:jeisfeld,项目名称:Augendiagnose,代码行数:21,代码来源:XmpHandler.java


注:本文中的com.adobe.xmp.XMPException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。