
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
How to get an 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 )
- Related Articles
- How to apply Affine Transformation on an image in OpenCV Python?
- PyTorch – How to perform random affine transformation of an image?
- How to perform matrix transformation in OpenCV Python?
- How to create a transformation matrix with HTML5?
- HTML5 Canvas Transformation Matrix
- How to get resource ID using get_resource_id() function in PHP and PHP 8?
- How to apply a 3×3 convolution matrix using imageconvolution() in PHP?
- How to get or set the resolution of an image using imageresolution() function in PHP?
- PHP – How to get the modulus of an arbitrary precision number using bcmod() function?
- PHP – How to get the substitution character using mb_substitute_character()?
- How to get the clipping rectangle using imagegetclip() function in PHP?
- How to get random value out of an array in PHP?
- How to get the first element of an array in PHP?
- PHP – How to get the square root of an arbitrary precision number using bcsqrt() function?
- How to create an identity matrix using Numpy?
