简体   繁体   English

使用ExifTool读取元数据

[英]Read metadata with ExifTool

I'm trying to read illustrator file metadata value by using Exiftool. 我正在尝试使用Exiftool读取插图文件元数据值。 I tried as per below. 我尝试了如下。

File[] images = new File("filepath").listFiles();
ExifTool tool = new ExifTool(Feature.STAY_OPEN);
for(File f : images) {
    if (f.toString().contains(".ai"))
    {
        System.out.println("test "+tool.getImageMeta(f, Tag.DATE_TIME_ORIGINAL));
    }
}
tool.close(); 

Above code not printing any value. 以上代码不打印任何值。 I even tried this. 我甚至试过这个。

public static final File[] IMAGES = new File("filepath").listFiles();
ExifTool tool = new ExifTool(Feature.STAY_OPEN);
for (File f : IMAGES) {
System.out.println("\n[" + f.getName() + "]");
System.out.println(tool.getImageMeta(f, Format.NUMERIC,
Tag.values()));
}

Which only prints {IMAGE_HEIGHT=2245, IMAGE_WIDTH=5393} . 仅打印{IMAGE_HEIGHT=2245, IMAGE_WIDTH=5393} How do I call metadata values using Exiftool. 如何使用Exiftool调用元数据值。 Any advices and references links are highly appreciated. 任何建议和参考链接都非常感谢。

For the given API, it either; 对于给定的API,它要么;

1-does not contain the tag you are looking for 1 - 不包含您要查找的标签

2-the file itself might not have that tag filled 2 - 文件本身可能没有填充该标记

3-you might want to recreate your own using a more general tag command when calling exiftool.exe 3 - 您可能希望在调用exiftool.exe时使用更通用的标记命令重新创建自己的标记

Look in the source code and find the enum containing all the tags available to the API, that'll show you what you're restricted to. 查看源代码并找到包含API可用的所有标记的enum ,它将向您显示您受限制的内容。 But yeah, you might want to consider making your own class similar to the one you're using. 但是,你可能想考虑让你自己的班级类似于你正在使用的班级。 I'm in the midst of doing the same. 我正在做同样的事情。 That way you can store the tags in perhaps a set or HashMap instead of an enum and therefore be much less limited in tag choice. 这样你就可以将标签存储在一个集合或HashMap而不是enum ,因此在标签选择方面的限制要少得多。 Then, all you have to do is write the commands for the tags you want to the process's OutputStream and then read the results from the InputStream. 然后,您所要做的就是将您想要的标记的命令写入进程的OutputStream,然后从InputStream中读取结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM