Open In App

PHP | imagesetinterpolation() Function

The imagesetinterpolation() function is an inbuilt function in PHP which is used to set the interpolation method, setting an interpolation method affects the rendering of various functions such as the imagerotate() function.
Syntax: 
 

bool imagesetinterpolation( resource $image, int $method )

Parameters: This function accepts two parameters as mentioned above and described below: 
 



Return Value: This function returns TRUE on success or FALSE on failure.
Below examples illustrate the imagesetinterpolation() function in PHP:
Example 1: 
 




<?php
 
// Load the png image
$image = imagecreatefrompng(
 
// Set the interpolation
imagesetinterpolation($image, IMG_BLACKMAN);
 
// Rotate the image
$black = imagecolorallocate($image, 0, 0, 0);
$rotated = imagerotate($image, 20, $black);
 
// Output image to the browser
header('Content-type: image/png');
imagepng($rotated);
?>

Output: 
 



Example 2: 
 




<?php
 
// Load the png image
$image = imagecreatefrompng(
 
// Set the interpolation
imagesetinterpolation($image, IMG_POWER);
 
// Rotate the image
$black = imagecolorallocate($image, 0, 0, 0);
$rotated = imagerotate($image, 20, $black);
 
// Output image to the browser
header('Content-type: image/png');
imagepng($rotated);
?>

Output: 
 

Reference: https://www.php.net/manual/en/function.imagesetinterpolation.php
 


Article Tags :