$imagick = new Imagick("example.jpg"); // Load image $colorspace = $imagick->getImageColorspace(); // Get colorspace echo $colorspace; // RGB (or CMYK, etc.)
$imagick = new Imagick("example.jpg"); // Load image $colorspace = $imagick->getImageColorspace(); // Get colorspace if($colorspace == Imagick::COLORSPACE_RGB){ // Check if RGB $imagick->transformImageColorspace(Imagick::COLORSPACE_GRAY); // Convert to grayscale } $imagick->writeImage("example_grayscale.jpg"); // Save converted imageThe package library for Imagick is the PHP extension "imagick." This is an extension for PHP that provides a wrapper for the ImageMagick library, allowing for image manipulation and processing functionality in PHP.