Resimleri Hex Koduna çevirme algoritması ile ftp de bulunan tüm resimlerin benzer halini bulabilir ve alandan tasarruf edebilirsiniz.
Basit düzeyde görüntü işleme ve karşılaştırma için kullanabilirsiniz. Hatta veritabanına resmi işledikten sonra kaydedip daha sonra benzer resim karşılaştırması yapabilirsiniz.
$filename = "resim.jpg"; if (getimagesize($filename)) { list($width, $height) = getimagesize($filename); $exploded = explode('.', $filename); $ext = $exploded[count($exploded) - 1]; if (preg_match('/jpg|jpeg/i', $ext)) { $img = imagecreatefromjpeg($filename); } else if (preg_match('/png/i', $ext)) { $img = imagecreatefrompng($filename); } else if (preg_match('/gif/i', $ext)) { $img = imagecreatefromgif($filename); } else if (preg_match('/bmp/i', $ext)) { $img = imagecreatefrombmp($filename); } else { return 0; } $new_img = imagecreatetruecolor(8, 8); imagecopyresampled($new_img, $img, 0, 0, 0, 0, 8, 8, $width, $height); imagefilter($new_img, IMG_FILTER_GRAYSCALE); $colors = array(); $sum = 0; for ($i = 0; $i < 8; $i++) { for ($j = 0; $j < 8; $j++) { $color = imagecolorat($new_img, $i, $j) & 0xff; $sum += $color; $colors[] = $color; } } $avg = $sum / 64; $hash = ''; $curr = ''; $count = 0; foreach ($colors as $color) { if ($color > $avg) { $curr .= '1'; } else { $curr .= '0'; } $count++; if (!($count % 4)) { $hash .= dechex(bindec($curr)); $curr = ''; } } $c = $hash; echo $c; }
Yorumlar