
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get Affine Transformation Matrix in PHP using imageaffinematrixget
imageaffinematrixget() is an inbuilt function in PHP that is used to get an affine transformation matrix. This function is often used in linear algebra and computer graphics.
Syntax
array imageaffinematrixget(int $type, mixed $options)
Parameters
imageaffinematrixget() accepts only two parameters: $type and $options.
-
$type − The $type parameter specifies the integer to IMG_AFFINE constants.
IMG_AFFINE_TRANSLATE
IMG_AFFINE_SCALE
IMG_AFFINE_ROTATE
IMG_AFFINE_SHEAR_HORIZONTAL
IMG_AFFINE_SHEAR_VERTICAL
$options − If type is IMG_AFFINE_TRANSLATE or IMG_AFFINE_SCALE, options has to be an array with keys x and y, both having float values. If type is IMG_AFFINE_ROTATE, IMG_AFFINE_SHEAR_HORIZONTAL or IMG_AFFINE_SHEAR_VERTICAL, options has to be a float specifying the angle.
Return Values
It returns an affine transformation matrix, an array with keys from 0 to 5 and float values. On failure, it returns false.
Example 1: Using IMG_AFFINE_SCALE
<?php $matrix_scale = imageaffinematrixget(IMG_AFFINE_SCALE, array('x' => 2, 'y' => 3)); print_r($matrix_scale); ?>
Output
Array ( [0] => 2 [1] => 0 [2] => 0 [3] => 3 [4] => 0 [5] => 0 )
Example 2
<?php $angle = 280; // Get the image affine matrix using imageaffinematrixget() function $matrix_vertical = imageaffinematrixget(IMG_AFFINE_SHEAR_VERTICAL, $angle); // Output the matrix values print("<pre>".print_r($matrix_vertical, true)."</pre>"); ?>
Output
Array ( [0] => 1 [1] => -5.6712818196177 [2] => 0 [3] => 1 [4] => 0 [5] => 0 )