imageaffinematrixconcat 


gd apg

RETURN the concatenation of two affine transformation matrices, what is useful if multiple transformations should be applied to the same image in one go.





AFFINE

is a geometric transformation operation involving MATRICES, covering both, 2D and 3D environment.

Transformations are often used in linear algebra and computer graphics.

In geometric transformations of images, the pixel coordinate is mapped.

This means that, each pixel is localized by two coordinates, in the rectangular domain of the image.

Without going into more details about pixel mapping, let's get to what really matters: the AFFINE transformations.

There are several classes of pixel mapping, one is called AFFINE.

AFFINE transformations include: scaling, rotation, shearing and translation.



<?php

array|false imageaffinematrixconcat ( array $matrix1, array $matrix2 )


where,

$matrix1 = An ARRAY of affine transformation matrix 
                                     with keys 0 to 5  
and float values

$matrix2 
= An ARRAY of affine transformation matrix 
                                     with keys 0 to 5 
and float values
 
?>
 

  $matrix1   


An AFFINE ARRAY with keys 0 to 5 and FLOAT values.

KEYS MEANING
0 arr1_0x
1 arr1_1x
2 arr1_2y
3 arr1_3y
4 arr1_4
5 arr1_5
ed48


  $matrix2   


An AFFINE ARRAY with keys 0 to 5 and FLOAT values.

KEYS MEANING
0 arr2_0x
1 arr2_1x
2 arr2_2y
3 arr2_3y
4 arr2_4
5 arr2_5
ed48


 RETURNED VALUES 

RETURNED ARRAY INDEX MEANING
0 a
1 b
2 c
3 d
4 x
5 y
ed48


This function returns FALSE on failure.



  1 EXERCISE   

<?php

echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';

$dest_img = "png/PNG 088 01 0.png";

$dest_aff1 = "png/PNG 088 01 1.png";

$dest_aff2 = "png/PNG 088 01 2.png";

$dest_conci = "png/PNG 088 01 3.png";

$dest_concj = "png/PNG 088 01 4.png";

$dest_conc = "png/PNG 088 01 5.png";

$arr_clip = [ 'x' => 90, 'y' => 80, 
                          
'width' => 200, 'height' => 150 ];

$arr_affi = [ '0' => -1, '1' => 0, '2' => 0, 
                                           
'3' => -0.5, '4' => 0, '5' => 0 ];

$arr_affj = [ '0' => 1, '1' => 0, '2' => 0, 
                                           
'3' => 2, '4' => 0, '5' => 0 ];

$id_base = imagecreatetruecolor(300,300);

imageantialias($id_base, 1);

$colorln = imagecolorallocate($id_base, 255, 255, 0);
$colorfl = imagecolorallocate($id_base, 255, 255, 0);

$star = [ 191,90, 209,142, 264,143, 
             
220,177, 236,230, 191,199, 
             
146,231, 161,177, 119,143, 
             
172,143, 191,90 ];
             
$starv = 11;

$polystar = imagepolygon($id_base, $star, $starv, $colorln);
$polystarfl = 
imagefilledpolygon($id_base, $star, $starv, $colorfl);

// yellowstar
imagepng($id_base, $dest_img);
$id_affi = imageaffine($id_base, $arr_affi, $arr_clip);

// yellowstar1
imagepng($id_affi, $dest_aff1);
echo 
$dest_img;

// yellowstar2
$id_affj = imageaffine($id_base, $arr_affj, $arr_clip);
imagepng($id_affj, $dest_aff2);

// yellowstar3
$arr_conc = imageaffinematrixconcat($arr_affi, $arr_affj);
$id_conci = imageaffine($id_base, $arr_conc, $arr_clip);
imagepng($id_conci, $dest_conci);

// yellowstar4
$id_concj = imageaffine($id_base, $arr_conc, $arr_clip);
imagepng($id_concj, $dest_concj);

// yellowstar5
$id_conc = imageaffine($id_base, $arr_conc);
imagepng($id_conc, $dest_conc);
?>

<br><br><img src="<?php echo 
$dest_img; ?>" alt="<?php echo $dest_img; ?>">
<br><br><br>

<?php 
echo $dest_aff1 . '<br><br>';
print_r($arr_affi); 
echo 
'<br>';
print_r($arr_clip); ?>
<br><br><img src="<?php echo 
$dest_aff1; ?>" alt="<?php echo $dest_aff1; ?>">
<br><br><br>

<?php 
echo $dest_aff2 . '<br><br>';
print_r($arr_affj); 
echo 
'<br>';
print_r($arr_clip); ?>
<br><br><img src="<?php echo 
$dest_aff2; ?>" alt="<?php echo $dest_aff2; ?>">
<br><br><br>

<?php echo $dest_conci . '<br><br>';
print_r($arr_conc); 
echo 
'<br>';
print_r($arr_clip); ?>
<br><br><img src="<?php echo 
$dest_conci; ?>" alt="<?php echo $dest_conci; ?>">
<br><br><br>

<?php echo $dest_concj . '<br><br>';
print_r($arr_conc); 
echo 
'<br>';
print_r($arr_clip); ?>
<br><br><img src="<?php echo 
$dest_concj; ?>" alt="<?php echo $dest_concj; ?>">
<br><br><br>

<?php echo $dest_conc . '<br><br>';
print_r($arr_conc); ?>
<br><br><img src="<?php echo 
$dest_conc; ?>" alt="<?php echo $dest_conc; ?>">
<br><br>


 RESULT   

PNG 088 01 0.png

PNG 088 01 0.png apr


PNG 088 01 1.png

Array ( [0] => -1 [1] => 0 [2] => 0 [3] => -0.5 [4] => 0 [5] => 0 )

Array ( [x] => 90 [y] => 80 [width] => 200 [height] => 150 )


PNG 088 01 1.png apr


PNG 088 01 2.png

Array ( [0] => 1 [1] => 0 [2] => 0 [3] => 2 [4] => 0 [5] => 0 )

Array ( [x] => 90 [y] => 80 [width] => 200 [height] => 150 )


PNG 088 01 2.png apr


PNG 088 01 3.png

Array ( [0] => -1 [1] => 0 [2] => 0 [3] => -1 [4] => 0 [5] => 0 )

Array ( [x] => 90 [y] => 80 [width] => 200 [height] => 150 )


PNG 088 01 3.png apr


PNG 088 01 4.png

Array ( [0] => -1 [1] => 0 [2] => 0 [3] => -1 [4] => 0 [5] => 0 )

Array ( [x] => 90 [y] => 80 [width] => 200 [height] => 150 )


PNG 088 01 4.png apr


PNG 088 01 5.png

Array ( [0] => -1 [1] => 0 [2] => 0 [3] => -1 [4] => 0 [5] => 0 )

PNG 088 01 5.png apr