Imagick::affineTransformImage


wizard apg

TRANSFORMS one image as dictated by the affine matrix.



<?php

bool 
public Imagick::affineTransformImage(ImagickDraw $matrix);

?>

$matrix


The affine matrix.



AFFINE TRANSFORATION


In Euclidean geometry, an affine transformation, or an affinity (from the Latin, affinis, "connected with"), is a geometric transformation that preserves lines and parallelism (but not necessarily distances and angles).





This function returns a TRUE on success.



  1 EXERCISE   

<?php

// Run several times

$img1 = new Imagick(PATH2IMGW '/gif/E 01 01.gif');

$tmp1 'img/results/E 01 01af561.gif';

$drw1 = new ImagickDraw();

$ang1 deg2rad(mt_rand(0360));

// BEWARE of the following array terms

$affrot1 = [ "sx" => cos($ang1), "sy" => cos($ang1),
                 
"rx" => sin($ang1), "ry" => sin($ang1),
                 
"tx" => 0"ty" => ];
                 
$drw1->affine($affrot1);

$img1->affineTransformImage($drw1);

$Data $img1->getImageBlob();

$img imagecreatefromstring($Data);

imagegif($img$tmp1);

echo 
basename($tmp1); ?>
<br><br>
<img src="<?php echo $tmp1?>"
 alt="<?php echo $tmp1?>
 title="<?php echo $tmp1?>">


 RESULT   

Array
(
    [sx] => 0.43837114678908
    [sy] => 0.43837114678908
    [rx] => -0.89879404629917
    [ry] => 0.89879404629917
    [tx] => 0
    [ty] => 0
)


E 01 01af561.gif


img/results/E 01 01af561.gif apr