php8.5
Home/ Manual/ imagick / imagick/ Imagick::recolorImage

Imagick::recolorImage

PHP function Deprecated as of PECL imagick 3.4.4 Edit on GitHub ✎

(PECL imagick 2 >= 2.3.0, PECL imagick 3)

Recolors image

Function-3-4-4

Description

Imagick::recolorImage(array $matrix): bool

Translate, scale, shear, or rotate image colors. This method supports variable sized matrices but normally 5x5 matrix is used for RGBA and 6x6 is used for CMYK. The last row should contain the normalized values. 0x636

Parameters

matrix

The matrix containing the color values

Return Values

Success

Examples

Imagick::recolorImage()

php
<?php
function recolorImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $remapColor = [ 1, 0, 0,
        0, 0, 1,
        0, 1, 0,];

//$remapColor = [
//    1.438, -0.122, -0.016,  0, 0, -0.03,
//    -0.062,  1.378, -0.016,  0, 0,  0.05,
//    -0.062, -0.122, 1.483,   0, 0, -0.02,
//];

    @$imagick->recolorImage($remapColor);

    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

See Also

Source: reference/imagick/imagick/recolorimage.xml · from the official PHP manual (php/doc-en)