What I am trying to accomplish in PHP with GD or ImageMagick is the following:
I have one large image (say 2000 x 2000 pixels).. I would like to check if a second, s
I had a quick look in PHP's ImageMagick and GD and neither has a built in way of doing that. An approach could be to use ImageMagick to divide the larger image to smaller ones(same size as the smaller one) and start comparing them to the smaller one.
However this will be very slow I suppose.
You can do that with imagemagick if you use a system call in your PHP code. I don't know if you want to try this out but here is how it can be done:
/dev/null) 3>&1 1>&2 2>&3");
//result is something like "0 @ 251,263"
$res = explode("@",$output);
if($res[0]==0)
{
echo "Perfect match
";
$res = explode(",",$res[1]);
echo "width: ".$res[0];
echo "
";
echo "height: ".$res[1];
} else {
echo "Not match";
}
?>
I have tested the above code in a linux box with XAMPP for Linux 1.7.3a and ImageMagick 6.7.1-0 2011-07-10 Q16.
About the comparison I use the metric AE(Absolute Error) which counts how many pixels differ. The result is printed to the error stream(STERR). More about imagemagick's subimage search you can find here.
Good luck :)