本文整理汇总了Java中com.adobe.xmp.XMPMeta类的典型用法代码示例。如果您正苦于以下问题:Java XMPMeta类的具体用法?Java XMPMeta怎么用?Java XMPMeta使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XMPMeta类属于com.adobe.xmp包,在下文中一共展示了XMPMeta类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import com.adobe.xmp.XMPMeta; //导入依赖的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;
}
示例2: extract
import com.adobe.xmp.XMPMeta; //导入依赖的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);
}
示例3: createPaddedSourceImage
import com.adobe.xmp.XMPMeta; //导入依赖的package包/类
/**
* From the given URI this method creates a 360/180 padded image that is
* ready to be made a tiny planet.
*/
private Bitmap createPaddedSourceImage(Uri sourceImageUri, boolean previewSize) {
InputStream is = getInputStream(sourceImageUri);
if (is == null) {
Log.e(TAG, "Could not create input stream for image.");
dismiss();
}
Bitmap sourceBitmap = BitmapFactory.decodeStream(is);
is = getInputStream(sourceImageUri);
XMPMeta xmp = XmpUtil.extractXMPMeta(is);
if (xmp != null) {
int size = previewSize ? getDisplaySize() : sourceBitmap.getWidth();
sourceBitmap = createPaddedBitmap(sourceBitmap, xmp, size);
}
return sourceBitmap;
}
示例4: getInt
import com.adobe.xmp.XMPMeta; //导入依赖的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;
}
}
示例5: extractXMPMeta
import com.adobe.xmp.XMPMeta; //导入依赖的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;
}
示例6: setXMPMeta
import com.adobe.xmp.XMPMeta; //导入依赖的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) {
}
}
示例7: extract
import com.adobe.xmp.XMPMeta; //导入依赖的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());
}
}
示例8: processXmpDateTag
import com.adobe.xmp.XMPMeta; //导入依赖的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());
}
示例9: createXmpMetadata
import com.adobe.xmp.XMPMeta; //导入依赖的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);
}
}
示例10: writeXmp
import com.adobe.xmp.XMPMeta; //导入依赖的package包/类
private synchronized void writeXmp(Asset asset, XMPWriteBackOptions writeBackOptions, XMPHandler xmpHandler) {
try {
Node e = (Node)asset.adaptTo(Node.class);
Node metadataNode = e.getNode("jcr:content/metadata");
SimpleXmpToJcrMetadataBuilder metadataAdapter = new SimpleXmpToJcrMetadataBuilder();
XMPMeta xmpMeta = metadataAdapter.getXmpFromJcr(metadataNode);
String[] arr$ = this.xmpExcludes;
int len$ = arr$.length;
for(int i$ = 0; i$ < len$; ++i$) {
String exclude = arr$[i$];
String[] split = exclude.split(" ", 2);
if(split.length == 2) {
String ns = split[0];
String prop = split[1];
if(xmpMeta.doesPropertyExist(ns, prop)) {
log.debug("Excluding XMP property: {} {}", ns, prop);
xmpMeta.deleteProperty(ns, prop);
}
} else {
log.warn("Configuration xmp.excludes has entry that does not have the format \'<namespace> <property>\': {}", exclude);
}
}
xmpHandler.writeXmp(asset, xmpMeta, writeBackOptions);
} catch (Throwable var15) {
if(log.isDebugEnabled()) {
log.debug("Could not propagate xmp to renditions of asset: \'" + asset.getPath() + "\'", var15);
} else {
log.warn("Could not propagate xmp to renditions of asset \'{}\': {}", asset.getPath(), var15.getMessage());
}
}
}
示例11: getXmpObject
import com.adobe.xmp.XMPMeta; //导入依赖的package包/类
public static XMPMeta getXmpObject(Context context) {
try {
InputStream is = context.getContentResolver().openInputStream(
MasterImage.getImage().getUri());
return XmpUtilHelper.extractXMPMeta(is);
} catch (FileNotFoundException e) {
return null;
}
}
示例12: apply
import com.adobe.xmp.XMPMeta; //导入依赖的package包/类
@Override
public Bitmap apply(Bitmap bitmapIn, float scaleFactor, int quality) {
int w = bitmapIn.getWidth();
int h = bitmapIn.getHeight();
int outputSize = (int) (w / 2f);
ImagePreset preset = getEnvironment().getImagePreset();
Bitmap mBitmapOut = null;
if (preset != null) {
XMPMeta xmp = ImageLoader.getXmpObject(MasterImage.getImage().getActivity());
// Do nothing, just use bitmapIn as is if we don't have XMP.
if(xmp != null) {
bitmapIn = applyXmp(bitmapIn, xmp, w);
}
}
if (mBitmapOut != null) {
if (outputSize != mBitmapOut.getHeight()) {
mBitmapOut = null;
}
}
while (mBitmapOut == null) {
try {
mBitmapOut = getEnvironment().getBitmap(outputSize,
outputSize, BitmapCache.TINY_PLANET);
} catch (java.lang.OutOfMemoryError e) {
System.gc();
outputSize /= 2;
Log.v(LOGTAG, "No memory to create Full Tiny Planet create half");
}
}
nativeApplyFilter(bitmapIn, bitmapIn.getWidth(), bitmapIn.getHeight(), mBitmapOut,
outputSize, mParameters.getZoom() / 100f, mParameters.getAngle());
return mBitmapOut;
}
示例13: extractXMPMeta
import com.adobe.xmp.XMPMeta; //导入依赖的package包/类
public static XMPMeta extractXMPMeta(InputStream is) {
return null;
}
示例14: getXMPMeta
import com.adobe.xmp.XMPMeta; //导入依赖的package包/类
/**
* Gets the XMPMeta object used to populate this directory. It can be used for more XMP-oriented operations.
* If one does not exist it will be created.
*/
@NotNull
public XMPMeta getXMPMeta()
{
if (_xmpMeta == null)
_xmpMeta = new XMPMetaImpl();
return _xmpMeta;
}
示例15: getExtendedXMPGUID
import com.adobe.xmp.XMPMeta; //导入依赖的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;
}