(PHP 5 >= 5.5.0, PHP 7, PHP 8)
imagesetinterpolation — Define el método de interpolación
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() .
imagemethodEl método de interpolación, que puede ser uno de los siguientes:
IMG_BELL : filtro Bell.
IMG_BESSEL : filtro Bessel.
IMG_BICUBIC : interpolación bicúbica.
IMG_BICUBIC_FIXED : implementación de punto fijo de una interpolación bicúbica.
IMG_BILINEAR_FIXED : implementación de punto fijo de una interpolación bilineal
(por defecto (incluyendo para la creación de imágenes)).
IMG_BLACKMAN : función de ventana Blackman.
IMG_BOX : filtro de desenfoque Box.
IMG_BSPLINE : interpolación Spline.
IMG_CATMULLROM : interpolación cubica Hermite spline.
IMG_GAUSSIAN : función Gaussiana.
IMG_GENERALIZED_CUBIC : interpolación fractal cubica generalizada spline.
IMG_HERMITE : interpolación Hermite.
IMG_HAMMING : filtro Hamming.
IMG_HANNING : filtro Hanning.
IMG_MITCHELL : filtro Mitchell.
IMG_POWER : interpolación Power.
IMG_QUADRATIC : interpolación cuadrática inversa.
IMG_SINC : función Sinc.
IMG_NEAREST_NEIGHBOUR : interpolación del vecino más cercano.
IMG_WEIGHTED4 : filtro Weighting.
IMG_TRIANGLE : interpolación Triangle.
| 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.
|
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...
?>La modificación del método de interpolación afecta a las siguientes funciones durante el rendimiento:
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 );
?>