如何通过Perl模块获取图像的元数据?

Léo*_* 준영 0 perl metadata image

我通过MacPorts安装了以下组件:

p5-image-info @1.16 (perl, graphics)
Extract meta information from image files
Run Code Online (Sandbox Code Playgroud)

它在其网站上说你可以使用它

   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];
Run Code Online (Sandbox Code Playgroud)

但是,我运行不成功

$perl  use Image::Info qw(image_info);
-bash: syntax error near unexpected token `('
$
Run Code Online (Sandbox Code Playgroud)

如何通过Perl模块获取图像的元数据?

Aln*_*tak 5

所描述的语法是如何在Perl脚本中使用它,而不是如何将它作为shell中的单行使用.

把它放在.pl文件中(例如"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));
}
Run Code Online (Sandbox Code Playgroud)

然后运行它:

$ ./image_info.pl file.jpg
Run Code Online (Sandbox Code Playgroud)

并陶醉在它会告诉你的大量信息中......

  • Masi,将/ usr/bin/perl更改为/ opt/local/bin/perl以使用随MacPorts安装的Perl安装. (2认同)