昨天晚上睡觉之前,我再次浏览了Learning Perl的
Scalar Data部分并看到了以下句子:
the ability to have any character in a string means you can create,scan,and manipulate raw binary data as strings.
一个想法立即打击我,我实际上可以让Perl扫描我存储在硬盘上的图片,以检查它们是否包含Adobe字符串.通过这样做,我可以分辨出哪些已被拍照.所以我尝试实现这个想法并提出以下代码:
#!perl use autodie; use strict; use warnings; { local $/="\n\n"; my $dir = 'f:/TestPix/'; my @pix = glob "$dir/*"; foreach my $file (@pix) { open my $pic,'<',"$file"; while(<$pic>) { if (/Adobe/) { print "$file\n"; } } } }
令人兴奋的是,代码似乎真的很有效,它可以过滤出已经过photoshopped的图片.但问题是许多图片是由其他公用事业编辑的.我想我有点卡在那里.我们是否有一些简单但通用的方法来判断数字图片是否已被编辑,例如
if (!= /the origianl format/) {...}
或者我们只需添加更多条件?喜欢
if (/Adobe/|/ACDSee/|/some other picture editors/)
有什么想法吗?或者由于我的编程知识极其有限,我还是过于简单化了?
一如既往地感谢任何指导.