PHP | Imagick colorMatrixImage() Function
The Imagick::colorMatrixImage() function is an inbuilt function in PHP which is used to apply color transformation to the images. This function induces saturation changes, hue rotation, luminance to alpha, and various other effects. This function uses variable-size transformation matrices i.e. 5×5 matrix for RGBA and 6×6 matrix for CMYKA.
bool Imagick::colorMatrixImage( array $color_matrix = Imagick::CHANNEL_DEFAULT )
Parameters: This function accepts single parameter $color_matrix which is used to hold a 5×5 matrix for RGBA with the rows meaning red, green, blue, alpha output, and the columns being red, green, blue, alpha input, whereas last row and columns for brightness adjustment. In 6×6 matrix for CMYKA with the rows meaning Cyan, Magenta, Yellow, Key or black, alpha output, and the columns being Cyan, Magenta, Yellow, Key or black, alpha input, whereas alpha for brightness adjustment similarly in RGBA, CMYKA also have last row and columns for brightness adjustment.
Return Value: This function returns True on success and return False on failure.
Below program illustrates the Imagick::colorMatrixImage() function in PHP: