PHP | Imagick affineTransformImage() Function
The Imagick::affineTransformImage() function is an inbuilt function in PHP which is used to transform an image as dictated by the affine matrix.
Syntax:
bool Imagick::affineTransformImage( $matrix )
Parameters: This function accepts single parameter $matrix which holds the value of affine matrix either based on rotate, sheer, scale, etc, …
Return Value: This function returns True on success and FALSE on failure.
Below program illustrates the Imagick::affineTransformImage() function in PHP:
Program: This program uses Imagick::affineTransformImage() function to transforms an image by affine given affine matrix.
<?php
$imagick = new \Imagick(
$imagickDraw = new \ImagickDraw();
$theta = "35" ;
$affineRotate = array (
"sx" => cos ( $theta ), "sy" => cos ( $theta ),
"rx" => sin( $theta ), "ry" => -sin( $theta ),
"tx" => 0, "ty" => 0,
);
$imagickDraw ->affine( $affineRotate );
$imagick ->setImageFormat( "png" );
$imagick ->affineTransformImage( $imagickDraw );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagick.affinetransformimage.php
Last Updated :
20 Aug, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...