本文整理汇总了Java中org.apache.sanselan.ImageInfo.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java ImageInfo.getHeight方法的具体用法?Java ImageInfo.getHeight怎么用?Java ImageInfo.getHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.sanselan.ImageInfo
的用法示例。
在下文中一共展示了ImageInfo.getHeight方法的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);
}
}
示例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;
}
示例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();
}