用perl找到图片信息

来源:互联网 发布:说明书排版设计软件 编辑:程序博客网 时间:2024/06/06 06:34

今天群里和彦问怎么把图片的按照图片生成日期重命名,sam给出Image::EXIF模块,回来试了试,觉得还不错,记录一下。

Exif(Exchangeable image file format):可交换图像文件格式常被简称为Exif,是专门为数码相机的照片设定的,可以记录数码照片的属性信息和拍摄数据。可以附加于JPEG、TIFF、RIFF等文件之中,为其增加有关数码相机拍摄信息的内容和索引图或图像处理软件的版本信息。Exif信息是可以被任意编辑的,因此只有参考的功能。


Image::EXIF(cpan:http://search.cpan.org/~ccpro/Image-EXIF-0.99.4/EXIF.pm)

作者在里面写到:Actually it's just a wrapper. Weak PHP's support of EXIF made me write it. If you wanna improve it - go ahead.I did this module only because nobody did it before.


查看图片的信息:

#!/usr/bin/perluse strict;use warnings;use Image::EXIF;use Data::Dumper;my $file_name = shift;my $exif = new Image::EXIF;$exif->file_name($file_name);print $exif->error ?        $exif->errstr : Dumper($all_info);

随便给了张照片,结果如下:


可以看到在‘other’里面有Image Generated的日期信息,这样就简单了,可以把时间找出来rename了。

0 0