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 paramter $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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

3 // Which corresponds to imagick::INTERPOLATE_BILINEAR.

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

7 // Which corresponds to imagick::INTERPOLATE_NEARESTNEIGHBOR.

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




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.