Windows - Perl, problem with : use Image::ExifTool ':Public';

Started by sylf, December 06, 2021, 10:30:21 AM

Previous topic - Next topic

sylf

Hello.
Not born yesterday, but new at Perl and new at Exiftool.
I need to extract metadata from thousands of images.
Wanting to follow https://exiftool.org/#library for editing a Perl Script, I just copied code below in a file.pl.
When running, I get this :
Quote
Can't locate Image/ExifTool.pm in @INC (you may need to install the Image::ExifTool module) (
@INC contains: c:/Users/fej/AppData/Local/activestate/cache/ccf3f037/site/lib c:/Users/fej/AppData/Local/activestate/cache/ccf3f037/lib) at rev_exiftool.pl line 3.
BEGIN failed--compilation aborted at rev_exiftool.pl line 3.
Your help would be much appreciated.
Best regards,
Sylvain

#!/usr/bin/perl -w
use Image::ExifTool ':Public';
#my $file = shift or die "Please specify filename";
my $file = shift or die "S:\Data\NT\Sylvain\php\images\_1060176.jpg";
my $info = ImageInfo($file);
foreach (keys %$info) {
    print "$_ : $info->{$_}\n";
}


Phil Harvey

Without installing them, the easiest way to make the ExifTool libraries available to a Perl script is to add them to the @INC before loading Image::ExifTool

#!/usr/bin/perl -w
BEGIN { unshift @INC, "<path to ExifTool lib directory>"; }
use Image::ExifTool ':Public';
...


- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

sylf

No error message any more, thank you.
I was expecting to get some metadata printed in my terminal as a result. Instead of this :
Quote
S:\Data\NT\Sylvain\php\images\_1060198.jpg at revillard_exiftool.pl line 5.
Same result with another image.
Any idea?
S

Phil Harvey

This is the "die" message in your script.  You need to run the script with a file name as an argument.  ie)

revillard_exiftool.pl S:\Data\NT\Sylvain\php\images\_1060198.jpg

The "shift" function gets the next argument from the command line.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

sylf

Thanks a lot, Phil, I've got plenty of metadata  :)
I have a lot to learn, but a first result is encouraging.
Sylvain