How can you get the metadata of an image by the Perl module?

好久不见. 提交于 2019-12-24 19:33:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!