• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • Imagick::recolorImage()

    (No version information available, might only be in Git)

    Recolors image

    说明

    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.此方法在Imagick基于ImageMagick 6.3.6以上版本编译时可用。

    参数

    $matrix

    The matrix containing the color values

    返回值

    成功时返回TRUE

    参见

    • Imagick::displayImage() Displays an image

    范例

    Example #1 Imagick::recolorImage()

    <?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();
    }
    ?>
    
    Simple example :
    <?php
    $image = new Imagick('test.jpg');
    $CMYK_color_model = array(0,100,0,0);
    $image->recolorImage($CMYK_color_model) ;
    header('Content-type: image/jpg');
    echo $image
    ?>