• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IImageMetadata类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getMetadata

import org.apache.sanselan.common.IImageMetadata; //导入依赖的package包/类
public IImageMetadata getMetadata(ByteSource byteSource, Map params)
        throws ImageReadException, IOException
{
    ArrayList chunks = readChunks(byteSource, new int[] { tEXt, zTXt, },
            true);

    if ((chunks == null) || (chunks.size() < 1))
        return null;

    ImageMetadata result = new ImageMetadata();

    for (int i = 0; i < chunks.size(); i++)
    {
        PNGTextChunk chunk = (PNGTextChunk) chunks.get(i);

        result.add(chunk.getKeyword(), chunk.getText());
    }

    return result;
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:21,代码来源:PngImageParser.java


示例2: getMetadata

import org.apache.sanselan.common.IImageMetadata; //导入依赖的package包/类
public IImageMetadata getMetadata(ByteSource byteSource, Map params)
		throws ImageReadException, IOException
{
	TiffImageMetadata exif = getExifMetadata(byteSource, params);

	/*JpegPhotoshopMetadata*/Object photoshop = null; /* getPhotoshopMetadata(byteSource,
			params);*/

	if (null == exif && null == photoshop)
		return null;

	JpegImageMetadata result = new JpegImageMetadata(photoshop, exif);

	return result;
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:16,代码来源:JpegImageParser.java


示例3: getMetadata

import org.apache.sanselan.common.IImageMetadata; //导入依赖的package包/类
public IImageMetadata getMetadata(ByteSource byteSource, Map params)
		throws ImageReadException, IOException
{
	FormatCompliance formatCompliance = FormatCompliance.getDefault();
	TiffContents contents = new TiffReader(isStrict(params)).readContents(
			byteSource, params, formatCompliance);

	ArrayList directories = contents.directories;

	TiffImageMetadata result = new TiffImageMetadata(contents);

	for (int i = 0; i < directories.size(); i++)
	{
		TiffDirectory dir = (TiffDirectory) directories.get(i);

		TiffImageMetadata.Directory metadataDirectory = new TiffImageMetadata.Directory(
				dir);

		ArrayList entries = dir.getDirectoryEntrys();

		for (int j = 0; j < entries.size(); j++)
		{
			TiffField entry = (TiffField) entries.get(j);
			metadataDirectory.add(entry);
		}

		result.add(metadataDirectory);
	}

	return result;
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:32,代码来源:TiffImageParser.java


示例4: getMetadata

import org.apache.sanselan.common.IImageMetadata; //导入依赖的package包/类
public final IImageMetadata getMetadata(File file, Map params)
		throws ImageReadException, IOException
{
	if (debug)
		System.out.println(getName() + ".getMetadata" + ": "
				+ file.getName());

	if (!canAcceptExtension(file))
		return null;

	return getMetadata(new ByteSourceFile(file), params);
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:13,代码来源:ImageParser.java


示例5: cameraMake

import org.apache.sanselan.common.IImageMetadata; //导入依赖的package包/类
/**
    * expects jpg file
    * @param file
    * @return String containing make of camera used to take jpg.
    */
private Map cameraMake(File file){
	TiffField make = null;
	HashMap<String,String> metaDataMap = new HashMap<>();
	try {
		IImageMetadata metadata = Sanselan.getMetadata(file);
		if(metadata != null){
		for(Object x : metadata.getItems()){
			String xString = x.toString();
			String[] arr = xString.split(": ");
			// make, model, time, location, Software
			if(arr[0].contains("Software") || 
					arr[0].toUpperCase().equals("MODEL") ||
					arr[0].toUpperCase().equals("MAKE") ||
					arr[0].toUpperCase().contains("CREATE DATE")){
			metaDataMap.put(arr[0], arr[1]);
			}
		}
		if (metadata instanceof JpegImageMetadata) {
		      make = ((JpegImageMetadata) metadata).findEXIFValue(ExifTagConstants.EXIF_TAG_MAKE);
		      ((JpegImageMetadata) metadata).dump();
		      
		}
		}
		} catch (Exception e) {
			e.printStackTrace();
	
		}
	
	return metaDataMap;
}
 
开发者ID:mcgyver5,项目名称:mngoat,代码行数:36,代码来源:PicturesServlet.java


示例6: displayMetaData

import org.apache.sanselan.common.IImageMetadata; //导入依赖的package包/类
private void displayMetaData(File file){
	 try {
		IImageMetadata metadata = Sanselan.getMetadata(file);
		if (metadata instanceof JpegImageMetadata) {
			TiffImageMetadata exif = null;
			TiffOutputSet outputSet = null;
		      TiffField dateTimeValue = ((JpegImageMetadata) metadata).findEXIFValue(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
		      TiffField model = ((JpegImageMetadata) metadata).findEXIFValue(ExifTagConstants.EXIF_TAG_LOCALIZED_CAMERA_MODEL);
		      TiffField make = ((JpegImageMetadata) metadata).findEXIFValue(ExifTagConstants.EXIF_TAG_MAKE);
		      ((JpegImageMetadata) metadata).dump();
		      if(make != null){
		    	  System.out.println(make);
		      }
		      
		      if(model != null){
		    	  String s = model.getStringValue();
		    	 // System.out.println(s + " SHOULD BE THE MODEL");
		      }
		
		      IImageMetadata metadata2 = Sanselan.getMetadata(file);
		  	JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata2;
		  	if (jpegMetadata != null) {
		  		exif = jpegMetadata.getExif();

		  		if (exif != null) {
		  			outputSet = exif.getOutputSet();
		  			//System.out.println(exif);
		  		}
		  	}
		      
		  } else {
			  System.out.println("Looks like metadata was not instanceof");
		  }
		
	} catch (Exception e) {
		System.out.println("some kind of error about could not get metadata from ");
		e.printStackTrace();
	}
	 
}
 
开发者ID:mcgyver5,项目名称:mngoat,代码行数:41,代码来源:RetrievePicture.java


示例7: process

import org.apache.sanselan.common.IImageMetadata; //导入依赖的package包/类
@Override
public Image process(Image image) throws Exception {
	String imageFileName = imageDirectory + File.separatorChar + image.getId() + '.' + image.getFormat();
	File file = new File(imageFileName);
	logger.debug("Image File " + imageFileName);
	if (!file.exists()) {
		logger.error("File {} does not exist in image directory for image ({}), {}, skipping record",
				file.getCanonicalPath(), image.getId(), image);
		imageAnnotator.annotate(image, AnnotationType.Error, AnnotationCode.BadField, "Unable to get embedded metadata as the local file was not found");
		return null;
	}
	boolean metadataFound = false;
	//Search for additional metadata
	Image embeddedMetadata = new Image();
	String xmpXml = Sanselan.getXmpXml(file);
	if (xmpXml != null && !xmpXml.isEmpty()) {
		logger.debug("Attempting to extract metadata from xmp-xml:\n" + xmpXml);
		try {
			XMPMetadata xmp = XMPMetadata.load(new InputSource(new StringReader(xmpXml)));
			for (Class schemaClass : schemas) {
				XMPSchema schema = xmp.getSchemaByClass(schemaClass);
				if (schema instanceof XMPSchemaIptc4xmpCore) {
					XMPSchemaIptc4xmpCore iptcSchema = (XMPSchemaIptc4xmpCore) schema;
					metadataFound = addIptcProperies(iptcSchema,embeddedMetadata) || metadataFound;
					logger.debug("Known schema that will be added:"	+ schema.toString() + "\n"
							+ schema.getElement().getTextContent());
				} else if (schema instanceof XMPSchemaDublinCore) {
					XMPSchemaDublinCore dcSchema = (XMPSchemaDublinCore) schema;
					metadataFound = addDcProperies(dcSchema, embeddedMetadata) || metadataFound;
					logger.debug("Known schema that will be added:"	+ schema.toString() + "\n"
							+ schema.getElement().getTextContent());
				} else if (schema instanceof XMPSchemaRightsManagement) {
					XMPSchemaRightsManagement rightsSchema = (XMPSchemaRightsManagement) schema;
					metadataFound = addRightsProprties(rightsSchema,embeddedMetadata) || metadataFound;
					logger.debug("Known schema that will be added:"	+ schema.toString() + "\n"
							+ schema.getElement().getTextContent());
				} else if (schema instanceof XMPSchemaPhotoshop) {
					XMPSchemaPhotoshop photoshopSchema = (XMPSchemaPhotoshop) schema;
					metadataFound = addPhotoshopProperties(photoshopSchema,	embeddedMetadata, image) || metadataFound;
					logger.debug("Known schema that will be added:"	+ schema.toString() + "\n"
							+ schema.getElement().getTextContent());
				} else {
					logger.info("Unable to process a schema of: " + schemaClass);
				}
			}
		} catch (IOException ioe) {
			logger.error("Exception parsing XMP XML for image (" + image.getId() + ") " + image
					+ " The XML was:\n" + xmpXml, ioe);
			imageAnnotator.annotate(image, AnnotationType.Warn, AnnotationCode.BadField, "There was an issue with the XMP metadata");
		}
	} else {
		logger.debug("Image " + file + " does not contain embedded XMP metadata");
	}

	try {
		IImageMetadata metadata = Sanselan.getMetadata(new File(imageFileName));
		if(metadata != null) {
			logger.debug("The metadata visible to Sanselan is: " +  metadata.toString("*"));
			metadataFound = addSanselanProperties(metadata, embeddedMetadata) || metadataFound;
		} else {
			logger.debug("There is no metadata available from Sanselan");
		}
	} catch (IOException | ImageReadException e) {
		logger.error("Error extracting information with Sanselan for image (" + image.getId() + ") " + image, e);
		imageAnnotator.annotate(image, AnnotationType.Warn, AnnotationCode.BadField, "There was an issue with EXIF metadata");
	}
	//Apply any supplementary metadata
	if(metadataFound && update(image, embeddedMetadata)) {
		validate(image);
		return image;
	} else {
		logger.debug("No metadata was updated, skipping");
		return null;
	}
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:76,代码来源:ImageMetadataExtractorImpl.java


示例8: getShootingTime

import org.apache.sanselan.common.IImageMetadata; //导入依赖的package包/类
public static Optional<LocalDateTime> getShootingTime(File image) {
	try {
		IImageMetadata metadata = Sanselan.getMetadata(image);
		if (metadata instanceof JpegImageMetadata) {
			TiffField dateTimeValue = ((JpegImageMetadata) metadata)
					.findEXIFValue(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
			if (dateTimeValue != null) {
				String stringValue = dateTimeValue.getStringValue().trim();

				String dateString = stringValue.split(" ")[0];
				String timeString = stringValue.split(" ")[1];

				String[] dateParts = dateString.split(":");
				String[] timeParts = timeString.split(":");

				LocalDate localDate = LocalDate.of(
						Integer.valueOf(dateParts[0]),
						Integer.valueOf(dateParts[1]),
						Integer.valueOf(dateParts[2]));
				LocalTime localTime = LocalTime.of(
						Integer.valueOf(timeParts[0]),
						Integer.valueOf(timeParts[1]),
						Integer.valueOf(timeParts[2]));

				return Optional.of(LocalDateTime.of(localDate, localTime));
			}
		}
	} catch (Exception e) {
		logger.error("Could not get metdata from {}", image, e);
	}
	return Optional.empty();
}
 
开发者ID:shaolinwu,项目名称:uimaster,代码行数:33,代码来源:ImageUtil.java


示例9: getMetadata

import org.apache.sanselan.common.IImageMetadata; //导入依赖的package包/类
public IImageMetadata getMetadata(ByteSource byteSource, Map params)
        throws ImageReadException, IOException
{
    TiffImageMetadata exif = getExifMetadata(byteSource, params);

    JpegPhotoshopMetadata photoshop = getPhotoshopMetadata(byteSource,
            params);

    if (null == exif && null == photoshop)
        return null;

    JpegImageMetadata result = new JpegImageMetadata(photoshop, exif);

    return result;
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:16,代码来源:JpegImageParser.java


示例10: getMetadata

import org.apache.sanselan.common.IImageMetadata; //导入依赖的package包/类
public IImageMetadata getMetadata(ByteSource byteSource, Map params)
        throws ImageReadException, IOException
{
    FormatCompliance formatCompliance = FormatCompliance.getDefault();
    TiffContents contents = new TiffReader(isStrict(params)).readContents(
            byteSource, params, formatCompliance);

    ArrayList directories = contents.directories;

    TiffImageMetadata result = new TiffImageMetadata(contents);

    for (int i = 0; i < directories.size(); i++)
    {
        TiffDirectory dir = (TiffDirectory) directories.get(i);

        TiffImageMetadata.Directory metadataDirectory = new TiffImageMetadata.Directory(
                dir);

        ArrayList entries = dir.getDirectoryEntrys();

        for (int j = 0; j < entries.size(); j++)
        {
            TiffField entry = (TiffField) entries.get(j);
            metadataDirectory.add(entry);
        }

        result.add(metadataDirectory);
    }

    return result;
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:32,代码来源:TiffImageParser.java


示例11: getMetadata

import org.apache.sanselan.common.IImageMetadata; //导入依赖的package包/类
public final IImageMetadata getMetadata(File file, Map params)
        throws ImageReadException, IOException
{
    if (debug)
        System.out.println(getName() + ".getMetadata" + ": "
                + file.getName());

    if (!canAcceptExtension(file))
        return null;

    return getMetadata(new ByteSourceFile(file), params);
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:13,代码来源:ImageParser.java


示例12: getMetadata

import org.apache.sanselan.common.IImageMetadata; //导入依赖的package包/类
private static IImageMetadata getMetadata(ByteSource byteSource, Map params)
		throws ImageReadException, IOException {
	ImageParser imageParser = getImageParser(byteSource);

	return imageParser.getMetadata(byteSource, params);
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:7,代码来源:Sanselan.java


示例13: addSanselanProperties

import org.apache.sanselan.common.IImageMetadata; //导入依赖的package包/类
/**
 * @param metadata
 * @param image
 * @return Whether any properties has been updated
 */
private boolean addSanselanProperties(IImageMetadata metadata, Image image) throws Exception {
	boolean isSomethingDifferent = false;
	if (metadata instanceof JpegImageMetadata) {
		JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
		StringBuffer keywords = null;
		StringBuffer spatial = null;

		for (Object o : jpegMetadata.getItems()) {
			if (o instanceof ImageMetadata.Item) {
				ImageMetadata.Item item = (ImageMetadata.Item) o;
				if (item.getKeyword().equals("Object Name") && image.getTitle() == null) {
					image.setTitle(sanitizer.sanitize(item.getText()));
					isSomethingDifferent = true;
				} else if (item.getKeyword().equals("Keywords")) {
					if (keywords == null) {
						keywords = new StringBuffer();
						keywords.append(item.getText());
					} else {
						keywords.append(", " + item.getText());
					}
				} else if (item.getKeyword().equals("Sublocation")
						|| item.getKeyword().equals("Province/State")
						|| item.getKeyword().equals("Country/Primary Location Name")) {
					if (spatial == null) {
						spatial = new StringBuffer();
						spatial.append(item.getText());
					} else {
						spatial.append(", " + item.getText());
					}
				}
			}
		}
		if (spatial != null && image.getSpatial() == null) {
			image.setSpatial(sanitizer.sanitize(spatial.toString()));
			isSomethingDifferent = true;
		}
		if (keywords != null && image.getSubject() == null) {
			image.setSubject(sanitizer.sanitize(keywords.toString()));
			isSomethingDifferent = true;
		}
		if (jpegMetadata.findEXIFValue(TiffConstants.TIFF_TAG_ARTIST) != null
				&& image.getCreator() == null) {
			image.setCreator(sanitizer.sanitize(jpegMetadata.findEXIFValue(
					TiffConstants.TIFF_TAG_ARTIST).getStringValue()));
			isSomethingDifferent = true;
		}
		if (jpegMetadata.findEXIFValue(TiffConstants.TIFF_TAG_COPYRIGHT) != null
				&& image.getRights() == null) {

			image.setRights(sanitizer.sanitize(jpegMetadata.findEXIFValue(
					TiffConstants.TIFF_TAG_COPYRIGHT).getStringValue()));
			isSomethingDifferent = true;
		}
		if (jpegMetadata.findEXIFValue(TiffConstants.TIFF_TAG_IMAGE_DESCRIPTION) != null
				&& image.getDescription() == null) {
			image.setDescription(sanitizer.sanitize(jpegMetadata.findEXIFValue(
					TiffConstants.TIFF_TAG_IMAGE_DESCRIPTION)
					.getStringValue()));
			isSomethingDifferent = true;
		}
		TiffImageMetadata exifMetadata = jpegMetadata.getExif();
		if (exifMetadata != null) {
			TiffImageMetadata.GPSInfo gpsInfo = exifMetadata.getGPS();
			if (gpsInfo != null && image.getLocation() == null) {
				image.setLongitude(gpsInfo.getLongitudeAsDegreesEast());
				image.setLatitude(gpsInfo.getLatitudeAsDegreesNorth());
				isSomethingDifferent = true;
			}
		}
	}
	return isSomethingDifferent ;
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:78,代码来源:ImageMetadataExtractorImpl.java


示例14: getMetadata

import org.apache.sanselan.common.IImageMetadata; //导入依赖的package包/类
public IImageMetadata getMetadata(ByteSource byteSource, Map params)
		throws ImageReadException, IOException
{
	return null;
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:6,代码来源:IcnsImageParser.java


示例15: getMetadata

import org.apache.sanselan.common.IImageMetadata; //导入依赖的package包/类
public IImageMetadata getMetadata(ByteSource byteSource, Map params)
        throws ImageReadException, IOException
{
    return null;
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:6,代码来源:GifImageParser.java


示例16: getMetadata

import org.apache.sanselan.common.IImageMetadata; //导入依赖的package包/类
private static IImageMetadata getMetadata(ByteSource byteSource, Map params)
        throws ImageReadException, IOException {
    ImageParser imageParser = getImageParser(byteSource);

    return imageParser.getMetadata(byteSource, params);
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:7,代码来源:Sanselan.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BadgeStyle类代码示例发布时间:2022-05-22
下一篇:
Java DatabaseException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap