/** * {@inheritdoc} */ public function apply(ImageInterface $image) { $image->usePalette($this->palette)->strip(); if (is_callable($this->path)) { $path = call_user_func($this->path, $image); } elseif (null !== $this->path) { $path = $this->path; } else { return $image; } return $image->save($path, $this->options); }
/** * Ensures that the color mode of the passed image is RGB. * * @param ImageInterface $image * * @return ImageInterface $image The modified image */ private function toRGB(ImageInterface $image) { if ($image->palette()->name() == 'cmyk') { $image->usePalette(new RGB()); } return $image; }