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

发布于 2024-07-18 17:00:02 字数 654 浏览 3 评论 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模块获取图像的元数据?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

咋地 2024-07-25 17:00:02

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

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

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文