1

I'm using Image::ExifTool for my exif-needs.

But now, need ONLY to detect if an image has EXIF data or not, and Image::ExifTool returns some data all times (e.g. returns metadata from file stat too, and internal image detecting). So,

#!/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";
    }
}

prints many "Found" tags, but the file doesn't contain any exif information.

Is here some easy way how to detect than the image really has or not EMBEDEDD exif data with Image::ExifTool?

If someone need additional informations: Having and image img.jpg with exif data, so:

$ exif --list-tags --no-fixup img.jpg

#or
$ identify -format '%[exif:*]' img.jpg

print many tags. Now

$ cp img.jpg img2.jpg
$ mogrify -strip img2.jpg   #removing all exif data, so

$ exif --list-tags --no-fixup img2.jpg

prints

Corrupt data
The data provided does not follow the specification.
ExifLoader: The data supplied does not seem to contain EXIF data.

and

$ identify -format '%[exif:*]' img2.jpg

prints nothing. So the img2.jpg hasn't exif data. But the above perl script still prints many "Found" tags.

4

1 回答 1

2

尝试调用 $ext->GetInfo('EXIF:*') 以仅获取 EXIF 信息。

  • 菲尔
于 2013-06-25T12:45:02.053 回答