0

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

p5-image-info @1.16 (perl, graphics)
Extract meta information from image files

它在其网站上说您可以通过以下方式使用它

   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];

但是,我运行不成功

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

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

4

2 回答 2

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));
}

并这样运行它:

$ ./image_info.pl file.jpg

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

于 2009-04-25T15:47:52.943 回答
0

阅读 http://perldoc.perl.org/perlrun.html

于 2009-04-25T17:09:39.690 回答