Thursday, February 12, 2026
HomeLanguagesPHP | imageaffinematrixconcat() Function

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:




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

RELATED ARTICLES

Most Popular

Dominic
32497 POSTS0 COMMENTS
Milvus
128 POSTS0 COMMENTS
Nango Kala
6869 POSTS0 COMMENTS
Nicole Veronica
11996 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12090 POSTS0 COMMENTS
Shaida Kate Naidoo
7009 POSTS0 COMMENTS
Ted Musemwa
7246 POSTS0 COMMENTS
Thapelo Manthata
6958 POSTS0 COMMENTS
Umr Jansen
6947 POSTS0 COMMENTS