/** * {@inheritdoc} */ public function usePalette(PaletteInterface $palette) { if (!isset(static::$colorspaceMapping[$palette->name()])) { throw new InvalidArgumentException(sprintf('The palette %s is not supported by Gmagick driver', $palette->name())); } if ($this->palette->name() === $palette->name()) { return $this; } try { try { $hasICCProfile = (bool) $this->gmagick->getimageprofile('ICM'); } catch (\GmagickException $e) { $hasICCProfile = false; } if (!$hasICCProfile) { $this->profile($this->palette->profile()); } $this->profile($palette->profile()); $this->setColorspace($palette); $this->palette = $palette; } catch (\GmagickException $e) { throw new RuntimeException('Failed to set colorspace', $e->getCode(), $e); } return $this; }
/** * {@inheritdoc} */ public function getColorProfile() { try { $data = $this->gmagick->getimageprofile('ICM'); } catch (\GmagickException $exception) { return null; } return new ColorProfile(StreamUtils::create($data)); }