protected function load($size = null) { try { $magick = new \Gmagick(); if ($this->format === IMG_JPG && $size !== null) { $magick->setsize($size[0], $size[1]); } $magick->readimage($this->filename); } catch (\Exception $e) { throw new \Imagine\Exception\RuntimeException("Gmagick: Unable to open image {$this->filename}. {$e->getMessage()}", $e->getCode(), $e); } if ($this->format === IMG_JPG && $size !== null) { $newWidth = $magick->getimagewidth(); if ($newWidth !== $this->size[0]) { $this->size = $this->prescalesize = array($newWidth, $magick->getimageheight()); } } $cs = $magick->getimagecolorspace(); $this->image = new Image($magick, RImagine::createPalette($cs), $this->metadata); if ($cs === \Gmagick::COLORSPACE_CMYK) { // convert CMYK > RGB try { $this->image->usePalette(new RGB()); } catch (\Exception $e) { $this->image->getGmagick()->stripimage(); // make sure all profiles are removed } } }