问题
I installed the following component by MacPorts:
p5-image-info @1.16 (perl, graphics)
Extract meta information from image files
It says in its website that you can use it by
Usage is something like this:
use Image::Info qw(image_info);
@info = image_info("filename");
$refto_hash_describing_1st_image = $info[0];
$refto_hash_describing_2nd_image = $info[1];
However, I run unsuccessfully
$perl use Image::Info qw(image_info);
-bash: syntax error near unexpected token `('
$
How can you get the metadata of an image by the Perl module?
回答1:
The syntax described is how you would use it within a Perl script, not how you can use it as a single line from the shell.
Put this in a .pl file (e.g. "image_info.pl"):
#!/usr/bin/perl -w
use strict;
use Image::Info qw[image_info];
use Data::Dumper;
while (@ARGV) {
print Dumper(image_info(shift));
}
And run it thus:
$ ./image_info.pl file.jpg
and revel in the masses of information it will tell you...
回答2:
Read http://perldoc.perl.org/perlrun.html
来源:https://stackoverflow.com/questions/789162/how-can-you-get-the-metadata-of-an-image-by-the-perl-module