in reply to compare images
If you know the images have not been modified after being uploaded, then you could compare checksums (MD5 or SHA) for each file. An example might progress like:
use strict; use Digest::MD5; my (%files); my $md5 = Digest::MD5->new; foreach my $dir ( @ARGV ) { next unless (-d $dir); foreach my $f (<$dir/*>) { next if (-d $f); open(FILE, $f) or die qq{Can't open $f: $!\n}; binmode(FILE); $md5->addfile(*FILE); close(FILE); push(@{$files{$md5->hexdigest}}, $f); $md5->reset; } } print qq{The following entries appear to be duplicates, }; print qq{and warrant closer examination:\n}; foreach my $k ( keys %files ) { if ( scalar @{$files{$k}} > 1 ) { print qq{\t}, q{Checksum: }, $k, qq{\n}; print qq{\t\t}, join( qq{\n\t\t}, @{$files{$k}} ), qq{\n}; } }
This will give you output that looks like the following (actual file names changed to protect the clueless):
$ ./compare-test.pl . The following entries appear to be duplicates, and warrant closer examination: Checksum: d41d8cd98f00b204e9800998ecf8427e ./file-01.txt ./file-1.txt ./file01.txt ./file1.txt Checksum: 520bd68306a6bd9aa586a80ee692c750 ./file-2.txt ./file2.txt Checksum: 024cde173d464feee746320b300b5c35 ./file-04.txt ./file04.txt Checksum: 3ef60d5a2fa552f395e154bb5418893c ./file-5.txt ./file5.txt
Hope that helps.
|
|---|