Open In App

PHP | imageaffinematrixconcat() Function

Last Updated : 17 Dec, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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:




<?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);
?>


Output:

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

Program 2:




<?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);
?>


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



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads