note 47235 added to ref.image

From: Date: Mon, 08 Nov 2004 04:03:32 +0000
Subject: note 47235 added to ref.image
Groups: php.notes 
Request: Send a blank email to php-notes+get-80259@lists.php.net to get a copy of this message
A simple image compare function. It scans 2 images pixel by pixel, from left to right and from top to bottom, if all pixels have equal colors it will return 'True', otherwise it will return 'False'. $img1 and $img2 must be of type image. (see usage) ---------------------------------------------- function imagecompare( &$img1,&$img2 ) { if (imagesx($img1)!=imagesx($img2) OR imagesy($img1)!=imagesy($img2)){ return False; break; } for( $x=0; $x<imagesx($img1 ); $x++ ){ for ($y=0; $y<imagesy($img1); $y++) { if(imagecolorat($img1,$x,$y)!=imagecolorat($img2,$x,$y)){ return False; break; } } } return True; break; } ---------------------------------------------- Sample usage: $im1=imagecreatefromgif("test1.gif"); $im2=imagecreatefromgif("test2.gif"); echo imagecompare(&$im1,&$im2); ---- Manual Page -- http://www.php.net/manual/en/ref.image.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47235 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47235&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47235&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47235&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47235&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47235&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47235&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47235&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#80259) next »