PHP | Imagick setColorspace() Function Last Updated : 17 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The Imagick::setColorspace() function is an inbuilt function in PHP which is used to set the global colorspace value of an image. Syntax: bool Imagick::setColorspace( int $colorspace ) Parameters: This function accepts a single parameter $colorspace which holds an integer value corresponding to one of COLORSPACE constants. imagick::COLORSPACE_UNDEFINED (0) imagick::COLORSPACE_RGB (1) imagick::COLORSPACE_GRAY (2) imagick::COLORSPACE_TRANSPARENT (3) imagick::COLORSPACE_OHTA (4) imagick::COLORSPACE_LAB (5) imagick::COLORSPACE_XYZ (6) imagick::COLORSPACE_YCBCR (7) imagick::COLORSPACE_YCC (8) imagick::COLORSPACE_YIQ (9) imagick::COLORSPACE_YPBPR (10) imagick::COLORSPACE_YUV (11) imagick::COLORSPACE_CMYK (12) imagick::COLORSPACE_SRGB (13) imagick::COLORSPACE_HSB (14) imagick::COLORSPACE_HSL (15) imagick::COLORSPACE_HWB (16) imagick::COLORSPACE_REC601LUMA (17) imagick::COLORSPACE_REC709LUMA (19) imagick::COLORSPACE_LOG (21) imagick::COLORSPACE_CMY (22) Return Value: This function returns TRUE on success. Exceptions: This function throws ImagickException on error. Below given programs illustrate the Imagick::setColorspace() function in PHP: Program 1: php <?php // Create a new imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-9.png'); // Set the colorspace $imagick->setColorspace(imagick::COLORSPACE_RGB); // Get the colorspace $colorSpace = $imagick->getColorSpace(); // Display the colorspace echo $colorSpace; ?> Output: 1 Program 2: php <?php // Create a new imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-9.png'); // Set the colorspace $imagick->setColorspace(imagick::COLORSPACE_YIQ); // Get the colorspace $colorSpace = $imagick->getColorSpace(); // Display the colorspace echo $colorSpace; ?> Output: 9 Reference: https://www.php.net/manual/en/imagick.setcolorspace.php Comment More infoAdvertise with us Next Article PHP | ImagickPixel setColor() function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | Imagick setImageColorspace() Function The Imagick::setImageColorspace() function is an inbuilt function in PHP which is used to set the image colorspace. Syntax: bool Imagick::setImageColorspace( int $colorspace ) Parameters: This function accepts a single parameter $colorspace which holds an integer value corresponding to one of COLORS 1 min read PHP | Gmagick setimagecolorspace() Function The Gmagick::setimagecolorspace() function is an inbuilt function in PHP which is used to set the image colorspace. Syntax: Gmagick Gmagick::setimagecolorspace( int $colorspace ) Parameters: This function accepts a single parameter $colorspace which holds an integer corresponding to one of COLORSPAC 1 min read PHP | Imagick recolorImage() Function The Imagick::recolorImage() function is an inbuilt function in PHP which is used to translate, scale, shear, or rotate image colors. This function is used as the matrix size variable. Normally 5x5 matrix is used for RGBA and 6x6 is used for CMYK. Syntax:  bool Imagick::recolorImage( $matrix ) Param 2 min read PHP | Imagick recolorImage() Function The Imagick::recolorImage() function is an inbuilt function in PHP which is used to translate, scale, shear, or rotate image colors. This function is used as the matrix size variable. Normally 5x5 matrix is used for RGBA and 6x6 is used for CMYK. Syntax:  bool Imagick::recolorImage( $matrix ) Param 2 min read PHP | ImagickPixel setColor() function The ImagickPixel::setColor() function is an inbuilt function in PHP which is used to set the color of the ImagickPixel object. Syntax: bool ImagickPixel::setColor( string $color ) Parameters:This function accepts a single parameter $color which holds the color. Return Value: This function returns TR 1 min read PHP | ImagickPixel setColorValue() function The ImagickPixel::setColorValue() function is an inbuilt function in PHP which is used to set the normalized value of the provided color channel for a given ImagickPixel's color. The normalized value is a floating-point number between 0 and 1. Syntax: bool ImagickPixel::setColorValue( int $color, fl 2 min read Like