【问题标题】:How can you get the metadata of an image by the Perl module?如何通过 Perl 模块获取图像的元数据?
【发布时间】:2009-04-25 15:38:38
【问题描述】:

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

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

它在its website 中说您可以使用它

   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 模块获取图像的元数据?

【问题讨论】:

    标签: perl image metadata


    【解决方案1】:

    所描述的语法是您将如何在 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
    

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

    【讨论】:

    • 我收到以下错误消息dpaste.com/37750。我对脚本有 744 权限。
    • 该错误意味着它在您的 Perl5 搜索路径中找不到 Image::Info 模块。
    • 问题显然出在 MacPorts 上。我假设 MacPorts 可以将模块放入 PERL5LIB,这是我唯一的 Perl PATH。它显然没有这样做。您需要将模块放入您的 PERL5LIB 吗?
    • Masi,将 /usr/bin/perl 更改为 /opt/local/bin/perl 以使用您通过 MacPorts 安装的 Perl 安装。
    • 好的,所以把 /opt/local/lib/perl5/vendor_perl/5.8.9 放到 PERL5LIB 中
    【解决方案2】:

    【讨论】:

      猜你喜欢
      • 2014-10-06
      • 1970-01-01
      • 2019-08-30
      • 2011-06-06
      • 2022-07-09
      • 2015-07-11
      • 2013-02-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多