Файл: vendor/intervention/image/src/Drivers/Imagick/Analyzers/ColorspaceAnalyzer.php
Строк: 82
<?php
declare(strict_types=1);
namespace InterventionImageDriversImagickAnalyzers;
use Error;
use Imagick;
use InterventionImageAnalyzersColorspaceAnalyzer as GenericColorspaceAnalyzer;
use InterventionImageColorsCmykColorspace as Cmyk;
use InterventionImageColorsHslColorspace as Hsl;
use InterventionImageColorsHsvColorspace as Hsv;
use InterventionImageColorsOklabColorspace as Oklab;
use InterventionImageColorsOklchColorspace as Oklch;
use InterventionImageColorsRgbColorspace as Rgb;
use InterventionImageExceptionsAnalyzerException;
use InterventionImageInterfacesImageInterface;
use InterventionImageInterfacesSpecializedInterface;
class ColorspaceAnalyzer extends GenericColorspaceAnalyzer implements SpecializedInterface
{
/**
* @throws AnalyzerException
*/
public function analyze(ImageInterface $image): mixed
{
try {
return match ($image->core()->native()->getImageColorspace()) {
Imagick::COLORSPACE_CMYK => new Cmyk(),
Imagick::COLORSPACE_SRGB, Imagick::COLORSPACE_RGB => new Rgb(),
Imagick::COLORSPACE_HSL => new Hsl(),
Imagick::COLORSPACE_HSB => new Hsv(),
constant(Imagick::class . '::COLORSPACE_OKLAB') => new Oklab(),
constant(Imagick::class . '::COLORSPACE_OKLCH') => new Oklch(),
default => throw new AnalyzerException('Failed to analyze unknown colorspace'),
};
} catch (Error $e) {
throw new AnalyzerException('Failed to analyze colorspace', previous: $e);
}
}
}