Image
Color space
Channel no.
function transformImageColorspace($imagePath, $colorSpace, $channel)
{
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->transformimagecolorspace($colorSpace);
    $imagick->separateImageChannel($channel);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}