ExifTool Forum

ExifTool => Install Problems => Topic started by: sylf on December 06, 2021, 10:30:21 AM

Title: Windows - Perl, problem with : use Image::ExifTool ':Public';
Post by: sylf on December 06, 2021, 10:30:21 AM
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";
}

Title: Re: Windows - Perl, problem with : use Image::ExifTool ':Public';
Post by: Phil Harvey on December 06, 2021, 10:43:53 AM
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
Title: Re: Windows - Perl, problem with : use Image::ExifTool ':Public';
Post by: sylf on December 06, 2021, 11:01:57 AM
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
Title: Re: Windows - Perl, problem with : use Image::ExifTool ':Public';
Post by: Phil Harvey on December 06, 2021, 11:14:08 AM
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
Title: Re: Windows - Perl, problem with : use Image::ExifTool ':Public';
Post by: sylf on December 06, 2021, 11:33:02 AM
Thanks a lot, Phil, I've got plenty of metadata  :)
I have a lot to learn, but a first result is encouraging.
Sylvain