I suppose a somewhat simple solution would be to do a checksum on the images using md5()
.
Open a directory, loop through the files generating md5s, compare md5s, delete duplicates.
EDIT: Here's a script using hash_file()
<?php
$dir = "/full/path/to/images";
$checksums = array();
if ($h = opendir($dir)) {
while (($file = readdir($h)) !== false) {
// skip directories
if(is_dir($_="{$dir}/{$file}")) continue;
$hash = hash_file('md5', $_);
// delete duplicate
if (in_array($hash, $checksums)) {
unlink($_);
}
// add hash to list
else {
$checksums[] = $hash;
}
}
closedir($h);
}