本文整理汇总了Java中com.drew.metadata.exif.ExifIFD0Directory.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java ExifIFD0Directory.getInt方法的具体用法?Java ExifIFD0Directory.getInt怎么用?Java ExifIFD0Directory.getInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.drew.metadata.exif.ExifIFD0Directory
的用法示例。
在下文中一共展示了ExifIFD0Directory.getInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fixOrientation
import com.drew.metadata.exif.ExifIFD0Directory; //导入方法依赖的package包/类
public void fixOrientation() throws ImageMutationFailedException {
try {
Metadata metadata = originalImageMetaData();
ExifIFD0Directory exifIFD0Directory = metadata.getFirstDirectoryOfType(ExifIFD0Directory.class);
if (exifIFD0Directory == null) {
return;
} else if (exifIFD0Directory.containsTag(ExifIFD0Directory.TAG_ORIENTATION)) {
int exifOrientation = exifIFD0Directory.getInt(ExifIFD0Directory.TAG_ORIENTATION);
if(exifOrientation != 1) {
rotate(exifOrientation);
exifIFD0Directory.setInt(ExifIFD0Directory.TAG_ORIENTATION, 1);
}
}
} catch (ImageProcessingException | IOException | MetadataException e) {
throw new ImageMutationFailedException("failed to fix orientation", e);
}
}
示例2: getOrientation
import com.drew.metadata.exif.ExifIFD0Directory; //导入方法依赖的package包/类
private static int getOrientation(byte[] data) {
InputStream is = null;
try {
is = new ByteArrayInputStream(data);
Metadata metadata = ImageMetadataReader.readMetadata(is);
Collection<ExifIFD0Directory> directories = metadata.getDirectoriesOfType(ExifIFD0Directory.class);
for(ExifIFD0Directory directory : directories) {
if(directory.containsTag(ExifDirectoryBase.TAG_ORIENTATION)) {
return directory.getInt(ExifDirectoryBase.TAG_ORIENTATION);
}
}
return ExifInterface.ORIENTATION_NORMAL;
}
catch (Exception e) {
return ExifInterface.ORIENTATION_NORMAL;
}
finally {
if(is != null) try { is.close(); } catch(Exception ignore) {}
}
}