Open In App

PHP | Imagick setImageInterpolateMethod() Function

The Imagick::setImageInterpolateMethod() function is an inbuilt function in PHP which is used to set the interlace scheme of image.

Syntax: 



bool Imagick::setImageInterpolateMethod( int $method )

Parameters: This function accepts a single parameter $method which corresponds to one of INTERPOLATE constants. We can also pass the constant directly like 
setImageInterpolateMethod(imagick::INTERPOLATE_BICUBIC);.

List of INTERPOLATE constants are given below:  



Return Value: This function returns TRUE on success.

Below programs illustrate the Imagick::setImageInterpolateMethod() function in PHP:

Program 1:  




<?php
   
// Create a new imagick object
$imagick = new Imagick(
   
// Set the Interpolate Method
$imagick->setImageInterpolateMethod(imagick::INTERPOLATE_BILINEAR);
   
// Get the Interpolate Method
$interpolateScheme = $imagick->getImageInterpolateMethod();
echo $interpolateScheme;
?>

Output: 

3 // Which corresponds to imagick::INTERPOLATE_BILINEAR.

Program 2:  




<?php
   
// Create a new imagick object
$imagick = new Imagick(
   
// Set the Interpolate Method
$imagick->setImageInterpolateMethod(imagick::INTERPOLATE_NEARESTNEIGHBOR);
   
// Get the Interpolate Method
$interpolateScheme = $imagick->getImageInterpolateMethod();
echo $interpolateScheme;
?>

Output: 

7 // Which corresponds to imagick::INTERPOLATE_NEARESTNEIGHBOR.

Reference: https://www.php.net/manual/en/imagick.setimageinterpolatemethod.php
 


Article Tags :