$w1 = $d1['width']; $h1 = $d1['height']; $d2 = $image2->getImageGeometry(); $w2 = $d2['width']; $h2 = $d2['height']; if ($w1 == $w2 && $h1 == $h2) { $result = $image1->compareImages($image2, Imagick::METRIC_MEANSQUAREERROR); if ($result[1] > $percent) { $result[0]->setImageFormat("png"); $files[] = "{$path_key}.png"; file_put_contents("./images/output/{$path_key}.png", $result[0]); } } else { $files_error[] = "Images {$file1} and {$file2} have different sizes"; } } } if (!empty($files)) { $climate->comment("Please check files:"); foreach ($files as $file) { $climate->comment($file); } } else { $climate->Green('All files equal.'); } if (!empty($files_error)) { $climate->comment("Please check errors:"); foreach ($files_error as $error) { $climate->error($error); } }