|
Posted by Mike G. on 08/16/06 13:38
That of course, assumes you're using PHP 5. Instead of using that
technique, I would use the md5_file function instead.
http://us2.php.net/manual/en/function.md5-file.php
Cheers,
Mike G.
Rik wrote:
> 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]
|