Last night before going to bed, I looked again at the Learning Perl Scalar Data section and came across the following sentence:
The ability to have any character in a string means that you can create, scan, and process raw binary data as strings.
The idea immediately struck me that I really could let Perl scan the photos that I saved on my hard drive to see if they contained an Adobe string. It seems, doing this, I can say which of them was photoshop. So I tried to implement this idea and came up with the following code:
#!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"; } } } }
Surprisingly, the code really works, and it filters photos that were processed by Photoshop. But the problem is that many pictures are edited by other utilities. I seem to be stuck there. We have a simple but universal method to determine if a digital image has been edited or not, something like
if (!= /the origianl format/) {...}
Or do we just need to add additional conditions? as
if (/Adobe/|/ACDSee/|/some other picture editors/)
Any ideas on this? Or am I simplifying due to my slightly limited programming knowledge?
Thanks, as always, for any guidance.
source share