function subImageMatch($image_path) { $imagick = new \Imagick(realpath($image_path)); $imagick2 = clone $imagick; $imagick2->cropimage(40, 40, 250, 110); $imagick2->vignetteimage(0, 1, 3, 3); $similarity = null; $bestMatch = null; $comparison = $imagick->subImageMatch($imagick2, $bestMatch, $similarity); $comparison->setImageFormat('png'); header("Content-Type: image/png"); echo $comparison->getImageBlob(); }