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


Java ImageInfo.getWidth方法代码示例

本文整理汇总了Java中org.apache.sanselan.ImageInfo.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java ImageInfo.getWidth方法的具体用法?Java ImageInfo.getWidth怎么用?Java ImageInfo.getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.sanselan.ImageInfo的用法示例。


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

示例1: doMetaData

import org.apache.sanselan.ImageInfo; //导入方法依赖的package包/类
private ImageInfo doMetaData(ParserResultItem result,
		StreamLimiter streamLimiter) throws IOException {
	try {
		ImageInfo info = Sanselan.getImageInfo(
				streamLimiter.getNewInputStream(),
				streamLimiter.getOriginalFileName());
		if (info == null)
			return null;
		int width = info.getWidth();
		int height = info.getHeight();
		long area_size = (long) width * height;
		result.addField(ParserFieldEnum.image_width, width);
		result.addField(ParserFieldEnum.image_height, height);
		result.addField(ParserFieldEnum.image_area_size, area_size);
		result.addField(ParserFieldEnum.image_number,
				info.getNumberOfImages());
		result.addField(ParserFieldEnum.image_format, info.getFormatName());
		return info;
	} catch (ImageReadException e) {
		throw new IOException(e);
	}
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:23,代码来源:ImageParser.java

示例2: process

import org.apache.sanselan.ImageInfo; //导入方法依赖的package包/类
@Override
public final Image process(final Image image) throws Exception {

	String imageFileName = imageDirectory + File.separatorChar  + image.getId() + '.' + image.getFormat();
	File file = new File(imageFileName);
	if(!file.exists()) {
		logger.warn("File does not exist in image directory, skipping");
		imageAnnotator.annotate(image, AnnotationType.Error, AnnotationCode.BadData, "The local file was not found, so cannot be resized");
	} else {
		try {
			ImageInfo imageInfo = Sanselan.getImageInfo(file);
			Integer width = new Integer(imageInfo.getWidth());
			Integer height = new Integer(imageInfo.getHeight());
			logger.debug("Image " + imageFileName + " dimensions: " + width + " x " + height);

			if (width > MAX_IMAGE_DIMENSION || height > MAX_IMAGE_DIMENSION) {

				// shrink to no larger than MAX_IMAGE_DIMENSION * MAX_IMAGE_DIMENSION
				MogrifyCmd mogrify = new MogrifyCmd();
				if (searchPath != null) {
					mogrify.setSearchPath(searchPath);
				}
				IMOperation resize = new IMOperation();
				resize.addImage(imageFileName);
				logger.debug("resizing to no larger than " + MAX_IMAGE_DIMENSION.intValue()  + " * " + MAX_IMAGE_DIMENSION.intValue());
				resize.resize(MAX_IMAGE_DIMENSION.intValue(), MAX_IMAGE_DIMENSION.intValue(),'>');
				resize.addImage(imageFileName);
				mogrify.run(resize);

			} else {
				logger.info("No need to resize image as it is smaller than " + MAX_IMAGE_DIMENSION + "px x " + MAX_IMAGE_DIMENSION + "px");
			}
		} catch (Exception e) {
			logger.error("There was an error resizing the image", e);
			imageAnnotator.annotate(image, AnnotationType.Error, AnnotationCode.BadData, "The file could not be resized");
		}
	}
	return image;
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:40,代码来源:ImageResizerImpl.java

示例3: isResizeRequired

import org.apache.sanselan.ImageInfo; //导入方法依赖的package包/类
private boolean isResizeRequired(int resize_w, int resize_h, ImageInfo imageInfo) {
  return resize_w != imageInfo.getWidth() || resize_h != imageInfo.getHeight();
}
 
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:4,代码来源:BasicImageRewriter.java


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