mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 16:28:51 -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,27 +1,27 @@
|
|||||||
package net.filebot.mediainfo;
|
package net.filebot.mediainfo;
|
||||||
|
|
||||||
import static net.filebot.Logging.*;
|
import static net.filebot.Logging.*;
|
||||||
|
import static net.filebot.similarity.Normalization.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
import com.drew.imaging.ImageMetadataReader;
|
import com.drew.imaging.ImageMetadataReader;
|
||||||
import com.drew.imaging.ImageProcessingException;
|
|
||||||
import com.drew.metadata.Directory;
|
import com.drew.metadata.Directory;
|
||||||
import com.drew.metadata.Metadata;
|
import com.drew.metadata.Metadata;
|
||||||
import com.drew.metadata.Tag;
|
import com.drew.metadata.Tag;
|
||||||
|
|
||||||
public class ImageMetadata extends LinkedHashMap<String, String> {
|
public class ImageMetadata extends LinkedHashMap<String, String> {
|
||||||
|
|
||||||
public ImageMetadata(File file) throws ImageProcessingException, IOException {
|
public ImageMetadata(File file) {
|
||||||
|
try {
|
||||||
Metadata metadata = ImageMetadataReader.readMetadata(file);
|
Metadata metadata = ImageMetadataReader.readMetadata(file);
|
||||||
|
|
||||||
for (Directory directory : metadata.getDirectories()) {
|
for (Directory directory : metadata.getDirectories()) {
|
||||||
for (Tag tag : directory.getTags()) {
|
for (Tag tag : directory.getTags()) {
|
||||||
String value = tag.getDescription();
|
String v = tag.getDescription();
|
||||||
if (value != null && value.length() > 0) {
|
if (v != null && v.length() > 0) {
|
||||||
putIfAbsent(tag.getTagName(), tag.getDescription());
|
putIfAbsent(normalizeSpace(normalizePunctuation(tag.getTagName()), "_"), v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +31,9 @@ public class ImageMetadata extends LinkedHashMap<String, String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
debug.warning(e::toString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package net.filebot.mediainfo;
|
package net.filebot.mediainfo;
|
||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.*;
|
import static java.nio.charset.StandardCharsets.*;
|
||||||
import static net.filebot.Logging.*;
|
|
||||||
import static net.filebot.similarity.Normalization.*;
|
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.File;
|
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
|
// 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) {
|
if (streamKind == StreamKind.Image && streamNumber == 0) {
|
||||||
try {
|
|
||||||
ImageMetadata exif = new ImageMetadata(new File(get(StreamKind.General, 0, "CompleteName")));
|
ImageMetadata exif = new ImageMetadata(new File(get(StreamKind.General, 0, "CompleteName")));
|
||||||
exif.forEach((k, v) -> streamInfo.putIfAbsent(normalizeSpace(normalizePunctuation(k), "_"), v));
|
exif.forEach(streamInfo::putIfAbsent);
|
||||||
} catch (Throwable e) {
|
|
||||||
debug.warning(e::toString);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return streamInfo;
|
return streamInfo;
|
||||||
|
Loading…
Reference in New Issue
Block a user