// Load image $image = new \Imagick('example.jpg'); // Set color space $image->setImageColorspace(\Imagick::COLORSPACE_SRGB); // Save image $image->writeimage('output.jpg');
// Load image $image = new \Imagick('example.jpg'); // Convert to grayscale $image->setImageColorspace(\Imagick::COLORSPACE_GRAY); // Save image $image->writeimage('output.jpg');In this example, we load an image and then convert it to grayscale by setting the colorspace to COLORSPACE_GRAY. Finally, we save the modified image using the writeimage() function. Package library: The Imagick extension is part of the ImageMagick package, which is a popular image manipulation library used in various programming languages. Therefore, the Imagick setImageColorspace function is part of the Imagick extension in PHP, which is a wrapper around the ImageMagick library.