PHP | Imagick remapImage() Function Last Updated : 04 Dec, 2019 Comments Improve Suggest changes Like Article Like Report The Imagick::remapImage() function is an inbuilt function in PHP which is used to replace colors in an image with those defined by replacement. The colors are replaced with the closest possible color. Syntax: bool Imagick::remapImage( Imagick $replacement, int $dither ) Parameters:This function accepts two parameters as mentioned above and described below: $replacement: It specifies an Imagick object containing the replacement colors. $dither: It specifies an integer value corresponding to one of DITHERMETHOD constants. You can also pass constant directly like remapImage($replacement, imagick::DITHERMETHOD_RIEMERSMA);. List of all DITHERMETHOD constants are given below: imagick::DITHERMETHOD_UNDEFINED (0) imagick::DITHERMETHOD_NO (1) imagick::DITHERMETHOD_RIEMERSMA (2) imagick::DITHERMETHOD_FLOYDSTEINBERG (3) Return Value: This function returns TRUE on success. Exceptions: This function throws ImagickException on error. Below programs illustrate the Imagick::remapImage() function in PHP: Program 1: php <?php // Create a new Imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Create another Imagick object $replacement = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/20191130231936/areplace.png'); // Remap the image $imagick->remapImage($replacement, imagick::DITHERMETHOD_RIEMERSMA); // Display the image header("Content-Type: image/png"); echo $imagick->getImageBlob(); ?> Output: Program 2: php <?php // Create a new Imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/20190918234528/colorize1.png'); // Create another Imagick object $replacement = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/20191130231936/areplace.png'); // Remap the image $imagick->remapImage($replacement, imagick::DITHERMETHOD_FLOYDSTEINBERG); // Display the image header("Content-Type: image/png"); echo $imagick->getImageBlob(); ?> Output: Reference: https://www.php.net/manual/en/imagick.remapimage.php Comment More infoAdvertise with us Next Article PHP | Imagick remapImage() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | Imagick readImage() Function The Imagick::readImage() function is an inbuilt function in PHP which is used to read an image from filename. Syntax: bool Imagick::readImage( string $filename ) Parameters:This function accepts a single parameter $filename which holds the name of the file. It can also accept URL of the file. Return 1 min read PHP | Imagick readImages() Function The Imagick::readImages() function is an inbuilt function in PHP which is used to read images from an array of filenames and associate them to a single Imagick object. Syntax: bool Imagick::readImages( array $filenames ) Parameters:This function accepts a single parameter $filenames which holds an a 2 min read PHP | Imagick resampleImage() Function The Imagick::resampleImage() function is an inbuilt function in PHP which is used to resample the image to the desired resolution Syntax: bool Imagick::resampleImage( $x_resolution, $y_resolution, $filter, $blur ) Parameters: This function accepts four parameters as mentioned above and described bel 1 min read PHP | Imagick removeImage() Function The Imagick::removeImage() function is an inbuilt function in PHP which is used to remove an image from the image list. This function removes the current image which is pointed by the cursor. Syntax: bool Imagick::removeImage( void ) Parameters: This function doesnât accepts any parameters. Return V 1 min read PHP | Imagick writeImage() Function The Imagick::writeImage() function is an inbuilt function in PHP which is used to write an image to the specified filename. This function saves the image file in the same folder where your PHP script is located. Syntax: bool Imagick::writeImage( string $filename = NULL ) Parameters: This function ac 1 min read Like