/** * Constructor of the class * * @param \Imagick $image The Imagick instance */ public function __construct(\Imagick $image) { //Convert CMYK to RGB if ($image->getImageColorspace() === \Imagick::COLORSPACE_CMYK) { $profiles = $image->getImageProfiles('*', false); if (array_search('icc', $profiles) === false) { $image->profileImage('icc', file_get_contents(__DIR__ . '/icc/us_web_uncoated.icc')); } $image->profileImage('icm', file_get_contents(__DIR__ . '/icc/srgb.icm')); $image->transformImageColorspace(\Imagick::COLORSPACE_SRGB); } $this->image = $image; }
/** * {@inheritDoc} * * @return Imagick */ public static function createFromString($string) { $imagick = new \Imagick(); $imagick->readImageBlob($string); return new static($imagick); }
/** * Checks the library to use and returns its class * * @param string $library The library name (Gd, Imagick) * * @throws ImageException if the image library does not exists. * * @return string */ public static function getLibraryClass($library) { if (!$library) { $library = Libs\Imagick::checkCompatibility() ? self::LIB_IMAGICK : self::LIB_GD; } $class = 'Imagecow\\Libs\\' . $library; if (!class_exists($class)) { throw new ImageException('The image library is not valid'); } if (!$class::checkCompatibility()) { throw new ImageException("The image library '{$library}' is not installed in this computer"); } return $class; }