PHP 8.6.0 Beta 1 is available for testing

imagesetinterpolation

(PHP 5 >= 5.5.0, PHP 7, PHP 8)

imagesetinterpolationDefine el método de interpolación

Descripción

function imagesetinterpolation(GdImage $image, int $method = IMG_BILINEAR_FIXED ): bool

Define el método de interpolación; el hecho de definir un método de interpolación afecta el rendimiento de varias funciones en GD, como por ejemplo la función imagerotate() .

Parámetros

image
Un objeto GdImage , retornado por una de las funciones de creación de imágenes, como imagecreatetruecolor() .
method

El método de interpolación, que puede ser uno de los siguientes:

Valores devueltos

Esta función retorna true en caso de éxito o false si ocurre un error.

Historial de cambios

Versión Descripción
8.0.0 image ahora espera una instancia de GdImage ; anteriormente, se esperaba un recurso gd de tipo resource válido.

Ejemplos

Ejemplo #1 Ejemplo con imagesetinterpolation()

<?php
// Carga de la imagen
$im = imagecreate(500, 500);
// Por defecto, la interpolación es IMG_BILINEAR_FIXED; se utiliza en su lugar
// el filtro 'Mitchell':
imagesetinterpolation($im, IMG_MITCHELL);
// Se continúa trabajando con $im...
?>

Notas

La modificación del método de interpolación afecta a las siguientes funciones durante el rendimiento:

Véase también

Found A Problem?

Learn How To Improve This PageSubmit a Pull RequestReport a Bug
+add a note

User Contributed Notes 1 note

up
-1
shaun at slickdesign dot com dot au
8 years ago
Setting the interpolation does not carry through to any images created by imageaffine() or imagerotate(). It defaults to IMG_BILINEAR_FIXED and would need to be set on each generated image as required.
<?php
imagesetinterpolation( $image, IMG_NEAREST_NEIGHBOUR );
// Rotated using IMG_NEAREST_NEIGHBOUR
$rotated = imagerotate( $image, 45, $transparent );
// Rotated using IMG_BILINEAR_FIXED
$rotated_again = imagerotate( $rotated, 45, $transparent );
?>

Setting the interpolation to IMG_NEAREST_NEIGHBOUR can help to preserve details and prevent sampling issues when rotating an image at 90 degree increments, including when rotating clockwise.
<?php
// Rotated image can appear blurred and on a slight angle.
$rotated = imagerotate( $image, -360, $transparent );
// Similar to starting Image although it may still show a background or be on a slight angle.
imagesetinterpolation( $image, IMG_NEAREST_NEIGHBOUR );
$rotated = imagerotate( $image, -360, $transparent );
?>
+add a note

AltStyle によって変換されたページ (->オリジナル) /