PHP code example of reptily / php-image-diff
1. Go to this page and download the library: Download reptily/php-image-diff library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
reptily / php-image-diff example snippets
e = new ImageDiff\Compares("1.png", "2.png");
try {
$image->Diff();
$image->getDiffImage("diff.png");
} catch (Exception $e) {
var_dump($e);
}
e = new ImageDiff\Compares("1m.png", "2m.png");
$area = (new ImageDiff\Model\Area())
->setPositionX(350)
->setPositionY(50)
->setSizeWidth(190)
->setSizeHeight(160)
;
try {
$image->Diff(5.0, $area);
$result = $image->Result();
echo "Count all pixels: " . $result->getCountAllPixels() . "\n";
echo "Count error pixels: " . $result->getCountErrorPixels() . "\n";
echo "Error percentage: " . $result->getErrorPercentage() . "%\n";
$image->getDiffImage("diff.png");
} catch (Exception $e) {
var_dump($e);
}
bash
composer