I have get the image pixel of an image at the particular point using getImagePixelColor.
$pixel = $image -> getImagePixelColor($x,$y);
Now I have modified that pixel's color using some method and now I want to set the new color of that pixel.
How can I do ?
There is a setColor function. But I got the pixel from the Imagick class. But the setColor function is in the ImagickPixel class. So how can I do it ?
->getImagePixelColor()
returns an ImagickPixel object anyways, so$pixel->setColor(...);
is all you need:Ref: http://php.net/manual/en/imagick.getimagepixelcolor.php
ImagickPixel::setColor()
is the correct function but it is also necessary to sync the pixel Iterator so your manipulations are written back to the image.Here is a short yet (almost) complete example that reads an image file, manipulates each pixel, and dumps it to a browser: