本文整理汇总了Java中com.drew.metadata.exif.ExifSubIFDDirectory.getDate方法的典型用法代码示例。如果您正苦于以下问题:Java ExifSubIFDDirectory.getDate方法的具体用法?Java ExifSubIFDDirectory.getDate怎么用?Java ExifSubIFDDirectory.getDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.drew.metadata.exif.ExifSubIFDDirectory
的用法示例。
在下文中一共展示了ExifSubIFDDirectory.getDate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getImageDate
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入方法依赖的package包/类
Date getImageDate(File file) throws Exception {
try {
Metadata metadata = ImageMetadataReader.readMetadata(file);
ExifSubIFDDirectory exifSubIFDDirectory = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
int tagDatetimeOriginal = ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL;
ExifIFD0Directory exifIFD0Directory;
exifIFD0Directory = metadata.getFirstDirectoryOfType(ExifIFD0Directory.class);
int tagDatetime = ExifIFD0Directory.TAG_DATETIME;
if (exifSubIFDDirectory != null && exifSubIFDDirectory.getDate(tagDatetimeOriginal,
TimeZone.getDefault()) !=
null) {
return exifSubIFDDirectory.getDate(tagDatetimeOriginal, TimeZone.getDefault());
}
if (exifIFD0Directory != null && exifIFD0Directory.getDate(tagDatetime,
TimeZone.getDefault()) != null) {
return exifIFD0Directory.getDate(tagDatetime, TimeZone.getDefault());
}
throw new CouldNotParseDateException();
}
catch (ImageProcessingException | IOException e) {
throw new CouldNotParseDateException("File: " + file.getName());
}
}
示例2: getExifDate
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入方法依赖的package包/类
private Date getExifDate(byte[] imgRaw) throws ImageProcessingException, IOException {
Metadata metadata = ImageMetadataReader.readMetadata(
new BufferedInputStream(new ByteArrayInputStream(imgRaw)));
ExifSubIFDDirectory directory = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
if (directory == null) {
return null;
}
return directory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL);
}
示例3: Frame
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入方法依赖的package包/类
/**
* @param frameFile
*/
public Frame(final File frameFile) {
try {
path = frameFile.getCanonicalPath();
final Metadata metadata = ImageMetadataReader.readMetadata(frameFile);
final ExifSubIFDDirectory directory = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
if (directory != null) {
// Original TS
Date date = directory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL);
if (date == null) {
date = directory.getDate(ExifSubIFDDirectory.TAG_DATETIME);
}
if (date != null) {
ts = date.getTime();
} else {
throw new RuntimeException("Unable to load timestamp from image.");
}
// exposure time
final Rational exTimeR = directory.getRational(ExifSubIFDDirectory.TAG_EXPOSURE_TIME);
exposure = (1.0 * exTimeR.getNumerator()) / exTimeR.getDenominator();
} else {
throw new RuntimeException("Unable to load timestamp from image.");
}
} catch (final ImageProcessingException | IOException ex) {
throw new RuntimeException(ex);
}
}
示例4: rename
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入方法依赖的package包/类
public boolean rename() throws UnsupportedOperationException {
boolean resultat = true;
String name;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd-HH.mm.ss");
File newFile;
File folder = new File(this.config.getPath());
File[] listOfFiles = folder.listFiles();
for (File file : listOfFiles) {
int index = 1;
if (file.isFile()) {
int endIndex = file.getName().lastIndexOf(".");
String extention = "";
if (endIndex != -1) {
extention = file.getName().substring(endIndex + 1, file.getName().length()).toLowerCase();
}
if (extention.equals("jpg")) {
try {
Metadata metadata = ImageMetadataReader.readMetadata(file);
ExifSubIFDDirectory directory = metadata.getDirectory(ExifSubIFDDirectory.class);
Date date = directory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL);
date = this.addShift(date);
do {
name = file.getParent() + "/" + this.config.getName(dateFormat.format(date));
if (index > 1) {
name += "-" + index;
}
newFile = new File(name + "." + extention);
index++;
} while (!file.renameTo(newFile));
} catch (Exception e) {
resultat = false;
}
}
}
}
return resultat;
}
示例5: readImageInformation
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入方法依赖的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 );
}