本文整理汇总了Java中com.drew.metadata.exif.ExifDirectoryBase类的典型用法代码示例。如果您正苦于以下问题:Java ExifDirectoryBase类的具体用法?Java ExifDirectoryBase怎么用?Java ExifDirectoryBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExifDirectoryBase类属于com.drew.metadata.exif包,在下文中一共展示了ExifDirectoryBase类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getOrientation
import com.drew.metadata.exif.ExifDirectoryBase; //导入依赖的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) {}
}
}
开发者ID:staticbloc,项目名称:media,代码行数:22,代码来源:PhotoCaptureRequest.java
示例2: getJpegData
import com.drew.metadata.exif.ExifDirectoryBase; //导入依赖的package包/类
protected void getJpegData(byte[] toMatch, int i, List<Integer> offsets, int resultIndex) {
try {
Metadata reader = JpegMetadataReader
.readMetadata(new ByteArrayInputStream(Arrays.copyOfRange(toMatch, i - offsets.get(resultIndex), toMatch.length)));
ExifIFD0Directory info = reader.getFirstDirectoryOfType(ExifIFD0Directory.class);
String cameraMake = null;
String cameraModel = null;
if (info != null) {
cameraMake = info.getString(ExifDirectoryBase.TAG_MAKE);
cameraModel = info.getString(ExifDirectoryBase.TAG_MODEL);
}
for (Directory dir : reader.getDirectoriesOfType(GpsDirectory.class)) {
GpsDescriptor descriptor = new GpsDescriptor((GpsDirectory) dir);
Map<String, String> gpsInfoDict = new LinkedHashMap<>();
gpsInfoDict.put("Camera Make: ", cameraMake);
gpsInfoDict.put("Camera Model: ", cameraModel);
gpsInfoDict.put("Latitude: ", tagOrEmpty(descriptor.getGpsLatitudeDescription()));
gpsInfoDict.put("Longitude: ", tagOrEmpty(descriptor.getGpsLongitudeDescription()));
gpsInfoDict.put("Altitude: ", descriptor.getGpsAltitudeDescription());
gpsInfoDict.put("Altitude Reference: ", descriptor.getGpsAltitudeRefDescription());
gpsInfoDict.put("Timestamp: ", descriptor.getGpsTimeStampDescription());
if (notEmptyGPS(descriptor.getGpsLatitudeDescription(), descriptor.getGpsLongitudeDescription())) {
logGPS(gpsInfoDict);
wasGPSFound = true;
}
}
}
catch (IOException | ImageProcessingException e) {
e.printStackTrace();
}
}
开发者ID:ciphertechsolutions,项目名称:IO,代码行数:36,代码来源:MagicCarver.java
示例3: readImageInformation
import com.drew.metadata.exif.ExifDirectoryBase; //导入依赖的package包/类
public static ImageInformation readImageInformation(File imageFile) throws IOException, MetadataException, ImageProcessingException {
Metadata metadata = ImageMetadataReader.readMetadata(imageFile);
ExifDirectoryBase exifDirectoryBase = metadata.getFirstDirectoryOfType(ExifDirectoryBase.class);
JpegDirectory jpegDirectory = metadata.getFirstDirectoryOfType(JpegDirectory.class);
IptcDirectory ipTCdirectory = metadata.getFirstDirectoryOfType(IptcDirectory.class);
int orientation = 1;
Date dateTaken = null;
String uniqueID = "";
if( exifDirectoryBase != null )
{
if( exifDirectoryBase.containsTag(ExifIFD0Directory.TAG_ORIENTATION))
orientation = exifDirectoryBase.getInt(ExifIFD0Directory.TAG_ORIENTATION);
}
ExifSubIFDDirectory exifSubIFDDirectory = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
if( exifSubIFDDirectory != null )
{
if( exifSubIFDDirectory.containsTag( ExifDirectoryBase.TAG_IMAGE_UNIQUE_ID ))
uniqueID = exifSubIFDDirectory.getString(ExifDirectoryBase.TAG_IMAGE_UNIQUE_ID);
if( exifSubIFDDirectory.containsTag( ExifDirectoryBase.TAG_DATETIME ))
dateTaken = exifSubIFDDirectory.getDate( ExifDirectoryBase.TAG_DATETIME );
if( dateTaken == null && exifSubIFDDirectory.containsTag( ExifIFD0Directory.TAG_DATETIME_ORIGINAL ))
dateTaken = exifSubIFDDirectory.getDate(ExifDirectoryBase.TAG_DATETIME_ORIGINAL);
if( dateTaken == null && exifSubIFDDirectory.containsTag( ExifIFD0Directory.TAG_DATETIME_DIGITIZED ))
dateTaken = exifSubIFDDirectory.getDate(ExifDirectoryBase.TAG_DATETIME_DIGITIZED);
if( dateTaken == null )
dateTaken = getCreationTime( imageFile );
}
boolean hasDeleteTag = false;
if( ipTCdirectory != null && ipTCdirectory.getKeywords() != null )
{
if( containsCaseInsensitive( ipTCdirectory.getKeywords(), "delete") )
hasDeleteTag = true;
}
int width = jpegDirectory.getImageWidth();
int height = jpegDirectory.getImageHeight();
return new ImageInformation(orientation, width, height, hasDeleteTag, uniqueID, dateTaken );
}
开发者ID:Dotosoft,项目名称:dotoquiz-tools,代码行数:51,代码来源:ImageInformation.java
注:本文中的com.drew.metadata.exif.ExifDirectoryBase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论