PHP.mk документација

Imagick::compareImages

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

imagick.compareimages.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека imagick.compareimages.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
Imagick::compareImages

Референца за `imagick.compareimages.php` со подобрена типографија и навигација.

imagick.compareimages.php

Imagick::compareImages

(PECL imagick 2, PECL imagick 3)

Imagick::compareImagesСпоредува слика со реконструирана слика

= NULL

public Imagick::compareImages((PECL imagick 2, PECL imagick 3) $compare, int $metric): array

Returns an array containing a reconstructed image and the difference between images.

Параметри

compare

An image to compare to.

metric

Provide a valid metric type constant. Refer to this list of metric constants.

Вратени вредности

Returns an array containing a reconstructed image and the difference between images.

Errors/Exceptions

Фрла ImagickException при грешка.

Примери

Пример #1 Користење Imagick::compareImages():

Compare images and display the reconstructed image

<?php

$image1
= new imagick("image1.png");
$image2 = new imagick("image2.png");

$result = $image1->compareImages($image2, Imagick::METRIC_MEANSQUAREERROR);
$result[0]->setImageFormat("png");

header("Content-Type: image/png");
echo
$result[0];

?>

Белешки од корисници 2 забелешки

info at celeste-design dot de
пред 11 години
If you get the following non-descriptive error message:

Uncaught exception 'ImagickException' with message 'Compare images failed'

Check your picture dimensions! i compared a 21x20 png to a 20x20 png which resulted in that error. Took me forever to figure out that the dimensions have to be exactly the same.
Tim K and Sam M @netflix
пред 11 години
The *Absolute Error* metric is not listed as an available metric constant. However, you can still use it if needed by passing the internal constant definition for AE which is 1. This is useful when you wish to compare using a desired fuzz factor. Example:

<?php
// init the image objects
$image1 = new imagick();
$image2 = new imagick();

// set the fuzz factor (must be done BEFORE reading in the images)
$image1->SetOption('fuzz', '2%');

// read in the images
$image1->readImage("php_step29_actual.png");
$image2->readImage("php_step29_correct.png");

// compare the images using METRIC=1 (Absolute Error)
$result = $image1->compareImages($image2, 1);

// print out the result
echo "The image comparison 2% Fuzz factor is: " . $result[1];
?>
Навигација

Прелистувај сродни теми и функции.

На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.