本文整理汇总了Java中com.drew.metadata.exif.ExifSubIFDDirectory类的典型用法代码示例。如果您正苦于以下问题:Java ExifSubIFDDirectory类的具体用法?Java ExifSubIFDDirectory怎么用?Java ExifSubIFDDirectory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExifSubIFDDirectory类属于com.drew.metadata.exif包,在下文中一共展示了ExifSubIFDDirectory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDateFromImgEXIF
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入依赖的package包/类
/**
* @param f
* @return
* @throws IOException
*/
private String getDateFromImgEXIF(final File file) throws IOException {
String date = null;
if (file.isFile()) {
try {
final Metadata metadata = ImageMetadataReader
.readMetadata(file);
// obtain the Exif directory
final Directory directory = metadata
.getDirectory(ExifSubIFDDirectory.class);
if (null != directory) {
final Date tagDate = directory
.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL);
if (null != tagDate) {
date = this.sdf.format(tagDate);
}
}
} catch (final ImageProcessingException e) {
// e.printStackTrace();
}
}
return date;
}
示例2: getExifDate
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入依赖的package包/类
/**
*
* @param filePath
* @return
*/
private String getExifDate(File file) {
try {
Metadata metadata = ImageMetadataReader.readMetadata(file);
Directory directory = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
int dateTag = ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL;
if (directory != null && directory.containsTag(dateTag)) {
Date date = directory.getDate(dateTag, TimeZone.getDefault());
return new SimpleDateFormat("yyyy-MM-dd HH:mm").format(date);
} else {
return "";
}
} catch (ImageProcessingException | IOException ex) {
LOGGER.log(Level.INFO,
"Exif error for {0}: {1}",
new String[]{file.getName(), ex.getLocalizedMessage()}
);
return "";
}
}
示例3: isARW
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入依赖的package包/类
/**
* There is a bug in Metadata Extractor that misidentifies some TIFF files
* as ARW files. This method is here to verify if such a misidentification
* has taken place or not.
*
* XXX This method can be removed if https://github.com/drewnoakes/metadata-extractor/issues/217 is fixed
*/
public static boolean isARW(Metadata metadata) {
if (metadata == null) {
return false;
}
Collection<ExifSubIFDDirectory> directories = metadata.getDirectoriesOfType(ExifSubIFDDirectory.class);
for (ExifSubIFDDirectory directory : directories) {
if (
directory.containsTag(ExifSubIFDDirectory.TAG_COMPRESSION) &&
directory.getInteger(ExifSubIFDDirectory.TAG_COMPRESSION) != null &&
directory.getInteger(ExifSubIFDDirectory.TAG_COMPRESSION) == 32767
) {
return true;
}
}
return false;
}
示例4: getDate
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入依赖的package包/类
public Date getDate() {
Date date;
if (mExifDirectory.containsTag(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL)) {
date = mExifDirectory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL, TimeZone.getDefault());
} else {
long millis = 0;
try {
BasicFileAttributes attr = Files.readAttributes(mFile.toPath(), BasicFileAttributes.class);
millis = attr.lastModifiedTime().toMillis();
} catch (IOException ex) {
millis = mFile.lastModified();
} finally {
date = new Date(millis);
}
}
return date;
}
示例5: supports
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入依赖的package包/类
public boolean supports(Class<? extends Directory> directoryType) {
return directoryType == ExifIFD0Directory.class ||
directoryType == ExifSubIFDDirectory.class;
}
示例6: testGetNonExistentTagIsNullForAllTypes
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入依赖的package包/类
@Test
public void testGetNonExistentTagIsNullForAllTypes() throws Exception
{
assertNull(_directory.getString(ExifSubIFDDirectory.TAG_APERTURE));
assertNull(_directory.getInteger(ExifSubIFDDirectory.TAG_APERTURE));
assertNull(_directory.getDoubleObject(ExifSubIFDDirectory.TAG_APERTURE));
assertNull(_directory.getFloatObject(ExifSubIFDDirectory.TAG_APERTURE));
assertNull(_directory.getByteArray(ExifSubIFDDirectory.TAG_APERTURE));
assertNull(_directory.getDate(ExifSubIFDDirectory.TAG_APERTURE));
assertNull(_directory.getIntArray(ExifSubIFDDirectory.TAG_APERTURE));
assertNull(_directory.getLongObject(ExifSubIFDDirectory.TAG_APERTURE));
assertNull(_directory.getObject(ExifSubIFDDirectory.TAG_APERTURE));
assertNull(_directory.getRational(ExifSubIFDDirectory.TAG_APERTURE));
assertNull(_directory.getRationalArray(ExifSubIFDDirectory.TAG_APERTURE));
assertNull(_directory.getStringArray(ExifSubIFDDirectory.TAG_APERTURE));
}
示例7: testOrderOfSameType
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入依赖的package包/类
@Test
public void testOrderOfSameType()
{
Metadata metadata = new Metadata();
Directory directory2 = new ExifSubIFDDirectory();
Directory directory3 = new ExifSubIFDDirectory();
Directory directory1 = new ExifSubIFDDirectory();
metadata.addDirectory(directory1);
metadata.addDirectory(directory2);
metadata.addDirectory(directory3);
Collection<ExifSubIFDDirectory> directories = metadata.getDirectoriesOfType(ExifSubIFDDirectory.class);
assertNotNull(directories);
assertEquals(3, directories.size());
assertSame(directory1, directories.toArray()[0]);
assertSame(directory2, directories.toArray()[1]);
assertSame(directory3, directories.toArray()[2]);
}
示例8: testOrderOfDifferentTypes
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入依赖的package包/类
@Test
public void testOrderOfDifferentTypes()
{
Metadata metadata = new Metadata();
Directory directory1 = new ExifSubIFDDirectory();
Directory directory2 = new ExifThumbnailDirectory();
Directory directory3 = new ExifIFD0Directory();
metadata.addDirectory(directory1);
metadata.addDirectory(directory2);
metadata.addDirectory(directory3);
List<Directory> directories = new ArrayList<Directory>();
for (Directory directory : metadata.getDirectories()) {
directories.add(directory);
}
assertEquals(3, directories.size());
assertSame(directory1, directories.toArray()[0]);
assertSame(directory2, directories.toArray()[1]);
assertSame(directory3, directories.toArray()[2]);
}
示例9: getHeight
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入依赖的package包/类
private Integer getHeight(final Metadata metadata) {
Integer value = null;
ExifSubIFDDirectory directory = metadata.getDirectory(ExifSubIFDDirectory.class);
if (directory != null && directory.containsTag(ExifSubIFDDirectory.TAG_EXIF_IMAGE_HEIGHT)) {
value = directory.getInteger(ExifSubIFDDirectory.TAG_EXIF_IMAGE_HEIGHT);
} else {
JpegDirectory dir = metadata.getDirectory(JpegDirectory.class);
if (dir != null && dir.containsTag(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT)) {
value = dir.getInteger(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT);
}
}
return value;
}
示例10: Row
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入依赖的package包/类
Row(@NotNull File file, @NotNull Metadata metadata)
{
this.file = file;
this.metadata = metadata;
ExifIFD0Directory ifd0Dir = metadata.getDirectory(ExifIFD0Directory.class);
ExifSubIFDDirectory subIfdDir = metadata.getDirectory(ExifSubIFDDirectory.class);
ExifThumbnailDirectory thumbDir = metadata.getDirectory(ExifThumbnailDirectory.class);
if (ifd0Dir != null) {
manufacturer = ifd0Dir.getDescription(ExifIFD0Directory.TAG_MAKE);
model = ifd0Dir.getDescription(ExifIFD0Directory.TAG_MODEL);
}
boolean hasMakernoteData = false;
if (subIfdDir != null) {
exifVersion = subIfdDir.getDescription(ExifSubIFDDirectory.TAG_EXIF_VERSION);
hasMakernoteData = subIfdDir.containsTag(ExifSubIFDDirectory.TAG_MAKERNOTE);
}
if (thumbDir != null) {
Integer width = thumbDir.getInteger(ExifThumbnailDirectory.TAG_THUMBNAIL_IMAGE_WIDTH);
Integer height = thumbDir.getInteger(ExifThumbnailDirectory.TAG_THUMBNAIL_IMAGE_HEIGHT);
thumbnail = width != null && height != null
? String.format("Yes (%s x %s)", width, height)
: "Yes";
}
for (Directory directory : metadata.getDirectories()) {
if (directory.getClass().getName().contains("Makernote")) {
makernote = directory.getName().replace("Makernote", "").trim();
}
}
if (makernote == null) {
makernote = hasMakernoteData ? "(Unknown)" : "N/A";
}
}
示例11: testExtractMetadata
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入依赖的package包/类
@Test
public void testExtractMetadata() throws Exception
{
File withExif = new File("Tests/com/drew/metadata/exif/withExif.jpg");
Metadata metadata = JpegMetadataReader.readMetadata(withExif);
Assert.assertTrue(metadata.containsDirectory(ExifSubIFDDirectory.class));
Directory directory = metadata.getOrCreateDirectory(ExifSubIFDDirectory.class);
Assert.assertEquals("80", directory.getString(ExifSubIFDDirectory.TAG_ISO_EQUIVALENT));
}
示例12: testGetNonExistentTagIsNullForAllTypes
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入依赖的package包/类
@Test
public void testGetNonExistentTagIsNullForAllTypes() throws Exception
{
Assert.assertNull(_directory.getString(ExifSubIFDDirectory.TAG_APERTURE));
Assert.assertNull(_directory.getInteger(ExifSubIFDDirectory.TAG_APERTURE));
Assert.assertNull(_directory.getDoubleObject(ExifSubIFDDirectory.TAG_APERTURE));
Assert.assertNull(_directory.getFloatObject(ExifSubIFDDirectory.TAG_APERTURE));
Assert.assertNull(_directory.getByteArray(ExifSubIFDDirectory.TAG_APERTURE));
Assert.assertNull(_directory.getDate(ExifSubIFDDirectory.TAG_APERTURE));
Assert.assertNull(_directory.getIntArray(ExifSubIFDDirectory.TAG_APERTURE));
Assert.assertNull(_directory.getLongObject(ExifSubIFDDirectory.TAG_APERTURE));
Assert.assertNull(_directory.getObject(ExifSubIFDDirectory.TAG_APERTURE));
Assert.assertNull(_directory.getRational(ExifSubIFDDirectory.TAG_APERTURE));
Assert.assertNull(_directory.getRationalArray(ExifSubIFDDirectory.TAG_APERTURE));
Assert.assertNull(_directory.getStringArray(ExifSubIFDDirectory.TAG_APERTURE));
}
示例13: 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());
}
}
示例14: addFile
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入依赖的package包/类
private void addFile(Path file) {
try {
io.getOut().println(file.toString());
Metadata metadata = ImageMetadataReader.readMetadata(file.toFile());
ExifSubIFDDirectory directory = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
if (directory != null) {
addPhoto(directory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL),
file);
}
} catch (ImageProcessingException | IOException | SQLException ex) {
// Swallow
}
}
示例15: extract
import com.drew.metadata.exif.ExifSubIFDDirectory; //导入依赖的package包/类
/**
* Extracts the metadata from the specified path and returns a List of
* MultimediaMetadataDescriptor objects (one for each metadata entry).
*
* @param objectId ID of the multimedia object for which metadata will be generated.
* @param path Path to the file for which metadata should be extracted.
* @return List of MultimediaMetadataDescriptors. The list may be empty but must always be
* returned!
*/
@Override
public List<MultimediaMetadataDescriptor> extract(String objectId, Path path) {
return MetadataUtil
.getMetadataDirectoryOfType(path, ExifSubIFDDirectory.class)
.map(ifdDirectory -> Maps.transformValues(FIELDS, tag -> ifdDirectory.getObject(tag))
.entrySet().stream()
.filter(e -> e.getValue() != null)
.map(e -> MultimediaMetadataDescriptor
.of(objectId, this.domain(), e.getKey(), e.getValue()))
).orElse(Stream.empty()).collect(Collectors.toList());
}