|
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]
|