php - uncaught exception 'ImagickException' with message 'Compare images failed' -
this first time use imagemagick, , doing small test see if work want work; however, getting error 'compare images failed'. possible doing wrong since don't know how imagick works. open other suggestions, want compare 2 images few changes. testing code looks like:
<?php $image1 = new imagick(); $image2 = new imagick(); $image1->readimage("export/image1.jpg"); $image2->readimage("export/image2.jpg"); $result = $image1->compareimages($image2, 1); $result[0]->setimageformat("jpg"); echo $result[1] . '\n'; ?> the error looks this:
root@review1:/var/www/html# php export/image.php php fatal error: uncaught exception 'imagickexception' message 'compare images failed' in /var/www/html/export/image.php:6 stack trace: #0 /var/www/html/export/image.php(6): imagick->compareimages(object(imagick), 1) #1 {main} thrown in /var/www/html/export/image.php on line 6
for future users having same issue, got work. if try compare 2 images different dimensions, error appear. did fix re-size both images both have same dimensions. in case looks this:
$image1->resizeimage(400,400,imagick::filter_lanczos, 1); $image2->resizeimage(400,400,imagick::filter_lanczos, 1);
Comments
Post a Comment