You are here: Re: checking for duplicate images. « All PHP « IT news, forums, messages
Re: checking for duplicate images.

Posted by Rik on 08/16/06 09:36

Cleverbum@hotmail.com wrote:
> I wanted to check if two images on my server were the same, and had
> the bright idea of using:
>
> $a=imagecreatefromjpg("1.jpg");
> $b=imagecreatefromjpg("2.jpg");
>
> if($a==$b){
> echo "they match";
> }else{
> echo "they don't match";
> }
>
> But that won't work, I obviously can't use equality to compare them,
> but is there a way that I can?


Yup, it will give a different resource id, even if you use the same image.

I'm not sure wether this is good practise but:
$a = md5(file_get_contents('1.jpg');
$b = md5(file_get_contents('2.jpg');
if($a==$b){
echo "they match";
}else{
echo "they don't match";
}

Grtz,
--
Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация