mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 08:18:52 -05:00
MediaInfo does not support EXIF image metadata natively so we use the metadata-extractor library and implicitly merge that information in
This commit is contained in:
parent
f2b29f108c
commit
d2df8d8923
@ -1,35 +1,38 @@
|
||||
package net.filebot.mediainfo;
|
||||
|
||||
import static net.filebot.Logging.*;
|
||||
import static net.filebot.similarity.Normalization.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import com.drew.imaging.ImageMetadataReader;
|
||||
import com.drew.imaging.ImageProcessingException;
|
||||
import com.drew.metadata.Directory;
|
||||
import com.drew.metadata.Metadata;
|
||||
import com.drew.metadata.Tag;
|
||||
|
||||
public class ImageMetadata extends LinkedHashMap<String, String> {
|
||||
|
||||
public ImageMetadata(File file) throws ImageProcessingException, IOException {
|
||||
Metadata metadata = ImageMetadataReader.readMetadata(file);
|
||||
public ImageMetadata(File file) {
|
||||
try {
|
||||
Metadata metadata = ImageMetadataReader.readMetadata(file);
|
||||
|
||||
for (Directory directory : metadata.getDirectories()) {
|
||||
for (Tag tag : directory.getTags()) {
|
||||
String value = tag.getDescription();
|
||||
if (value != null && value.length() > 0) {
|
||||
putIfAbsent(tag.getTagName(), tag.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
if (directory.hasErrors()) {
|
||||
for (String error : directory.getErrors()) {
|
||||
debug.warning(error);
|
||||
for (Directory directory : metadata.getDirectories()) {
|
||||
for (Tag tag : directory.getTags()) {
|
||||
String v = tag.getDescription();
|
||||
if (v != null && v.length() > 0) {
|
||||
putIfAbsent(normalizeSpace(normalizePunctuation(tag.getTagName()), "_"), v);
|
||||
}
|
||||
}
|
||||
|
||||
if (directory.hasErrors()) {
|
||||
for (String error : directory.getErrors()) {
|
||||
debug.warning(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
debug.warning(e::toString);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
package net.filebot.mediainfo;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.*;
|
||||
import static net.filebot.Logging.*;
|
||||
import static net.filebot.similarity.Normalization.*;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
@ -153,12 +151,8 @@ public class MediaInfo implements Closeable {
|
||||
|
||||
// MediaInfo does not support EXIF image metadata natively so we use the metadata-extractor library and implicitly merge that information in
|
||||
if (streamKind == StreamKind.Image && streamNumber == 0) {
|
||||
try {
|
||||
ImageMetadata exif = new ImageMetadata(new File(get(StreamKind.General, 0, "CompleteName")));
|
||||
exif.forEach((k, v) -> streamInfo.putIfAbsent(normalizeSpace(normalizePunctuation(k), "_"), v));
|
||||
} catch (Throwable e) {
|
||||
debug.warning(e::toString);
|
||||
}
|
||||
ImageMetadata exif = new ImageMetadata(new File(get(StreamKind.General, 0, "CompleteName")));
|
||||
exif.forEach(streamInfo::putIfAbsent);
|
||||
}
|
||||
|
||||
return streamInfo;
|
||||
|
Loading…
Reference in New Issue
Block a user