PHP | Imagick mapImage() Function
Last Updated :
05 Sep, 2019
The Imagick::mapImage() function is an inbuilt function in PHP which is used to replace the colors of an image with the closest color from a reference image.
Syntax:
bool Imagick::mapImage( Imagick $map, float $dither )
Parameters: This function accepts two parameters as mentioned above and described below:
- $map: This parameter holds the Imagick object.
- $dither: This parameter holds a boolean which decides whether to add noise or not.
Return Value: This function returns TRUE on success.
Errors/Exceptions: This function throws ImagickException on error.
Below programs illustrate the Imagick::mapImage() function in PHP:
Program 1:
<?php
$imagick1 = new Imagick(
$imagick2 = new Imagick(
$imagick1 ->mapImage( $imagick2 , true);
header( "Content-Type: image/jpg" );
echo $imagick1 ->getImageBlob();
?>
|
Output:
Program 2:
<?php
$imagick1 = new Imagick(
$imagick2 = new Imagick(
$imagick1 ->mapImage( $imagick2 , false);
header( "Content-Type: image/jpg" );
echo $imagick1 ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagick.mapimage.php
Share your thoughts in the comments
Please Login to comment...