HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelTutorial Source codeReport an issue


← setColor   setColorValue →

Sets the color of one ImagickPixel from another ImagickPixel object.

This method is included for completeness; the underlying function is useful in the C programming language but in PHP it is easy to copy values around.

function setColorFromPixel()
    $image = new \Imagick();
    $draw = new \ImagickDraw();

    $stroke_color = new \ImagickPixel('black');

    $fill_color = new \ImagickPixel('red');
    $blue_color = new \ImagickPixel('blue');


    $draw->rectangle(200, 200, 300, 300);

    $image->newImage(500, 500, "gray");

    header("Content-Type: image/png");
    echo $image->getImageBlob();