Open In App

PHP | Imagick setImageInterpolateMethod() Function

Last Updated : 12 Jan, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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:  

  • imagick::INTERPOLATE_UNDEFINED (0)
  • imagick::INTERPOLATE_AVERAGE (1)
  • imagick::INTERPOLATE_BICUBIC (2)
  • imagick::INTERPOLATE_BILINEAR (3)
  • imagick::INTERPOLATE_FILTER (4)
  • imagick::INTERPOLATE_INTEGER (5)
  • imagick::INTERPOLATE_MESH (6)
  • imagick::INTERPOLATE_NEARESTNEIGHBOR (7)
  • imagick::INTERPOLATE_SPLINE (8)

Return Value: This function returns TRUE on success.

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

Program 1:  

PHP




<?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




<?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
 



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads