1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-20 12:41:23 +02:00

Change colorspace adjustment logic

This commit is contained in:
Oliver Vogel
2024-08-11 13:41:19 +02:00
parent e7554ec048
commit 9deb50b0bc

View File

@@ -17,13 +17,6 @@ use Intervention\Image\Modifiers\RemoveAnimationModifier;
class NativeObjectDecoder extends SpecializableDecoder implements SpecializedInterface
{
protected const SUPPORTED_COLORSPACES = [
Imagick::COLORSPACE_SRGB,
Imagick::COLORSPACE_CMYK,
Imagick::COLORSPACE_HSL,
Imagick::COLORSPACE_HSB,
];
public function decode(mixed $input): ImageInterface|ColorInterface
{
if (!is_object($input)) {
@@ -41,10 +34,10 @@ class NativeObjectDecoder extends SpecializableDecoder implements SpecializedInt
$input = $input->coalesceImages();
}
// turn image into rgb if colorspace if other than CMYK, RGB, HSL or HSV.
// this prevents working on greyscale colorspace images when loading
// from PNG color type greyscale format.
if (!in_array($input->getImageColorspace(), self::SUPPORTED_COLORSPACES)) {
// turn images with colorspace 'GRAY' into 'SRGB' to avoid working on
// greyscale colorspace images as this results images loosing color
// information when placed into this image.
if ($input->getImageColorspace() == Imagick::COLORSPACE_GRAY) {
$input->setImageColorspace(Imagick::COLORSPACE_SRGB);
}