note 47235 deleted from ref.image by tularis

From: Date: Sun, 29 Jun 2008 21:10:50 +0000
Subject: note 47235 deleted from ref.image by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-140966@lists.php.net to get a copy of this message
Note Submitter: Lost at LostLord dot com [Morteza Zafari] ---- 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) || imagesy($img1)!=imagesy($img2)){ return false; } 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; } } } return true; } ---------------------------------------------- Sample usage: $im1=imagecreatefromgif("test1.gif"); $im2=imagecreatefromgif("test2.gif"); echo imagecompare(&$im1,&$im2);

« previous php.notes (#140966) next »