【发布时间】:2013-06-21 09:47:09
【问题描述】:
我正在使用 Image::ExifTool 来满足我的 exif 需求。
但现在,只需要检测图像是否有 EXIF 数据,Image::ExifTool 会一直返回一些数据(例如,也从文件状态返回元数据,以及内部图像检测)。所以,
#!/usr/bin/perl
use 5.014;
use warnings;
use open qw(:std :utf8);
use Image::ExifTool qw(:Public);
use Data::Dumper;
my $ext = new Image::ExifTool;
while(<>) {
chomp;
next unless(-f $path);
if( $ext->ExtractInfo($path) ) {
say "$_" for (sort $ext->GetFoundTags());
}
else {
say "NO\t$path";
}
}
打印许多“找到”标签,但文件不包含任何 exif 信息。
这里有一些简单的方法来检测图像是否真的有或没有使用 Image::ExifTool 嵌入 exif 数据?
如果有人需要更多信息:拥有和图像 img.jpg 与 exif 数据,所以:
$ exif --list-tags --no-fixup img.jpg
#or
$ identify -format '%[exif:*]' img.jpg
打印许多标签。现在
$ cp img.jpg img2.jpg
$ mogrify -strip img2.jpg #removing all exif data, so
$ exif --list-tags --no-fixup img2.jpg
打印
Corrupt data
The data provided does not follow the specification.
ExifLoader: The data supplied does not seem to contain EXIF data.
和
$ identify -format '%[exif:*]' img2.jpg
什么都不打印。所以img2.jpg 没有exif 数据。但是上面的 perl 脚本仍然会打印出很多“Found”标签。
【问题讨论】: