PHP | imageaffinematrixconcat() Function

The imageaffinematrixconcat function is an inbuilt GD function in PHP which is used to concatenate two affine transformation matrices. To get affine transformation array using imageaffinematrixget() function of GD along with IMG_AFFINE_* constants.

Syntax:

array imageaffinematrixconcat( array $m1, array $m2 )

Parameters: This function accept two parameters as mentioned above and described below:

  • $m1: This parameter holds the affine transformation matrix which has an array with key 0 to 5 and float values.
  • $m2: This parameter holds the affine transformation matrix which has an array with key 0 to 5 and float values.

Return Value: It returns concatenated affine transformation matrices which has an array with key 0 to 5 and float values on success or False on failure.

Below programs illustrate the imageaffinematrixconcat() function in PHP:



Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// 1st Affine transformation matrix to be concatenate
$m1 = imageaffinematrixget(IMG_AFFINE_TRANSLATE,
                     array('x' => 12, 'y' => 23));
  
// 2nd Affine transformation matrix to be concatenate
$m2 = imageaffinematrixget(IMG_AFFINE_SCALE,
                     array('x' => 54, 'y' => 35));
  
// Concatenation process
$matrix = imageaffinematrixconcat($m1, $m2);
  
print_r($matrix);
?>

chevron_right


Output:

Array ( [0] => 54 [1] => 0 [2] => 0 [3] => 35 [4] => 648 [5] => 805 )

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// 1st Affine transformation matrix to be concatenate
$m1 = imageaffinematrixget(IMG_AFFINE_SHEAR_HORIZONTAL, 270);
  
// 2nd Affine transformation matrix to be concatenate
$m2 = imageaffinematrixget(IMG_AFFINE_ROTATE, 120);
  
// Concatenation process
$matrix = imageaffinematrixconcat($m1, $m2);
print_r($matrix);
?>

chevron_right


Output:

Array ( [0] => -0.5 [1] => 0.86602540378444 [2] => -2.7218732255326E+15
        [3] => 4.7144227183838E+15 [4] => 0 [5] => 0 )

Reference:
https://www.php.net/manual/en/function.imageaffinematrixconcat.php




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.