Imagick::distortImage

(PECL imagick 2 >= 2.0.1, PECL imagick 3)

Imagick::distortImageDistorts an image using various distortion methods

Descrição

publicImagick::distortImage(int$method, array$arguments, bool$bestfit): bool

Distorts an image using various distortion methods, by mapping color lookups of the source image to a new destination image usually of the same size as the source image, unless 'bestfit' is set to true.

If 'bestfit' is enabled, and distortion allows it, the destination image is adjusted to ensure the whole source 'image' will just fit within the final destination image, which will be sized and offset accordingly. Also in many cases the virtual offset of the source image will be taken into account in the mapping.

Este método estará disponível se a extensão Imagick tiver sido compilada com a ImageMagick versão 6.3.6 ou superior.

Parâmetros

method

The method of image distortion. See distortion constants

arguments

The arguments for this distortion method

bestfit

Attempt to resize destination to fit distorted source

Valor Retornado

Retorna true em caso de sucesso.

Erros/Exceções

Lança uma exceção ImagickException em caso de erro.

Exemplos

Exemplo #1 Using Imagick::distortImage():

Distort an image and display to the browser.

<?php

$im = new Imagick();


$im->newPseudoImage(100, 100, "pattern:checkerboard");


$im->setImageFormat('png');


$im->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);


$im->setImageMatte(true);


$controlPoints = array( 10, 10,
10, 5,

10, $im->getImageHeight() - 20,
10, $im->getImageHeight() - 5,

$im->getImageWidth() - 10, 10,
$im->getImageWidth() - 10, 20,

$im->getImageWidth() - 10, $im->getImageHeight() - 10,
$im->getImageWidth() - 10, $im->getImageHeight() - 30);


$im->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, true);


header("Content-Type: image/png");
echo
$im;
?>

O exemplo acima produzirá algo semelhante a:

Output of example : Using Imagick::distortImage()

Veja Também

To Top