Imagick::transformImageColorspace

Transforms an image to a new colorspace

&reftitle.description; public `bool` `Imagick::transformImageColorspace` `int` `colorspace`

Transforms an image to a new colorspace.

&reftitle.parameters;

`colorspace`

- The colorspace the image should be transformed to, one of the COLORSPACE constants e.g. Imagick::COLORSPACE_CMYK.

&reftitle.returnvalues;

&imagick.return.success;

&reftitle.examples;

### `Imagick::transformImageColorspace` example

Transforms an image to a new colorspace, and then extracts a single channel so that the individual channel values can be viewed.

    <?php
    function transformImageColorspace($imagePath, $colorSpace, $channel) {
        $imagick = new \Imagick(realpath($imagePath));
        $imagick->transformimagecolorspace($colorSpace);
        //channel should be one of the channel constants e.g. \Imagick::CHANNEL_BLUE
        $imagick->separateImageChannel($channel);
        header("Content-Type: image/jpg");
        echo $imagick->getImageBlob();
    }
    ?>

&reftitle.seealso;

- `Imagick::setColorSpace`