PHP | Imagick paintTransparentImage() Function
The Imagick::paintTransparentImage() function is an inbuilt function in PHP which is used to change any pixel that matches the color with the defined color.
Syntax:
bool Imagick::paintTransparentImage( $target, $alpha, $fuzz )
Parameters: This function accepts three parameters as mentioned above and described below:
- $target: It contains the value of target color to change the specified opacity value within the given range.
- $alpha: It contains the floating point value ranging from 0.0(fully transparent) to 1.0(fully opaque).
- $fuzz: It defines how much the tolerance is accepted to consider the two colors as the same.
Return Value: This function returns True on success.
Errors/Exceptions: This function throws ImagickException on error.
Below program illustrates the Imagick::paintTransparentImage() function in PHP:
Program:
<?php // Create a new Imagick object $imagick = new \Imagick( // Cloning the imagick object $paintit = clone $imagick; $quantum = $imagick->getQuantumDepth()['quantumDepthLong']; // Use Imagick::paintTransparentImage() function function // change the pixel color $paintit->paintTransparentImage("White", 0.2, 0.5 *$quantum); header("Content-Type: image/jpg"); // Display the output image echo $paintit->getImageBlob(); ?> |
Output:

Reference: https://www.php.net/manual/en/imagick.painttransparentimage.php
Recommended Posts:
- PHP | Imagick getImageColorspace() Function
- PHP | Imagick getImageGamma() Function
- PHP | Imagick getImageColors() Function
- PHP | Imagick vignetteImage() Function
- PHP | Imagick shadeImage() Function
- PHP | Imagick flipImage() Function
- PHP | Imagick brightnessContrastImage() Function
- PHP | Imagick getImageSignature() Function
- PHP | Imagick getInterlaceScheme() Function
- PHP | Imagick getImageTicksPerSecond() Function
- PHP | Imagick opaquePaintImage() Function
- PHP | Imagick randomThresholdImage() Function
- PHP | Imagick radialBlurImage() Function
- PHP | Imagick rollImage() Function
- PHP | Imagick identifyImage() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



