protected function setImageInfo()
{
// Set image object properties.
$this->width = $this->resource->getImageWidth();
$this->height = $this->resource->getImageHeight();
$this->depth = $this->resource->getImageDepth();
$this->quality = null;
$this->alpha = $this->resource->getImageAlphaChannel() == 1 ? true : false;
$colorSpace = $this->resource->getImageColorspace();
$type = $this->resource->getImageType();
switch ($colorSpace) {
case \Imagick::COLORSPACE_UNDEFINED:
$this->channels = 0;
$this->mode = '';
break;
case \Imagick::COLORSPACE_RGB:
if ($type == \Imagick::IMGTYPE_PALETTE) {
$this->channels = 3;
$this->mode = 'Indexed';
} else {
if ($type == \Imagick::IMGTYPE_PALETTEMATTE) {
$this->channels = 3;
$this->mode = 'Indexed';
} else {
if ($type == \Imagick::IMGTYPE_GRAYSCALE) {
$this->channels = 1;
$this->mode = 'Gray';
} else {
if ($type == \Imagick::IMGTYPE_GRAYSCALEMATTE) {
$this->channels = 1;
$this->mode = 'Gray';
} else {
$this->channels = 3;
$this->mode = 'RGB';
}
}
}
}
break;
case \Imagick::COLORSPACE_GRAY:
$this->channels = 1;
$this->mode = $type == \Imagick::IMGTYPE_PALETTE || $type == \Imagick::IMGTYPE_PALETTEMATTE ? 'Indexed' : 'Gray';
break;
case \Imagick::COLORSPACE_TRANSPARENT:
$this->channels = 1;
$this->mode = 'Transparent';
break;
case \Imagick::COLORSPACE_OHTA:
$this->channels = 3;
$this->mode = 'OHTA';
break;
case \Imagick::COLORSPACE_LAB:
$this->channels = 3;
$this->mode = 'LAB';
break;
case \Imagick::COLORSPACE_XYZ:
$this->channels = 3;
$this->mode = 'XYZ';
break;
case \Imagick::COLORSPACE_YCBCR:
$this->channels = 3;
$this->mode = 'YCbCr';
break;
case \Imagick::COLORSPACE_YCC:
$this->channels = 3;
$this->mode = 'YCC';
break;
case \Imagick::COLORSPACE_YIQ:
$this->channels = 3;
$this->mode = 'YIQ';
break;
case \Imagick::COLORSPACE_YPBPR:
$this->channels = 3;
$this->mode = 'YPbPr';
break;
case \Imagick::COLORSPACE_YUV:
$this->channels = 3;
$this->mode = 'YUV';
break;
case \Imagick::COLORSPACE_CMYK:
$this->channels = 4;
$this->mode = 'CMYK';
break;
case \Imagick::COLORSPACE_SRGB:
$this->channels = 3;
$this->mode = 'sRGB';
break;
case \Imagick::COLORSPACE_HSB:
$this->channels = 3;
$this->mode = 'HSB';
break;
case \Imagick::COLORSPACE_HSL:
$this->channels = 3;
$this->mode = 'HSL';
break;
case \Imagick::COLORSPACE_HWB:
$this->channels = 3;
$this->mode = 'HWB';
break;
case \Imagick::COLORSPACE_REC601LUMA:
$this->channels = 3;
$this->mode = 'Rec601';
break;
case \Imagick::COLORSPACE_REC709LUMA:
$this->channels = 3;
$this->mode = 'Rec709';
break;
case \Imagick::COLORSPACE_LOG:
$this->channels = 3;
$this->mode = 'LOG';
break;
case \Imagick::COLORSPACE_CMY:
$this->channels = 3;
$this->mode = 'CMY';
break;
}
}