{"record":{"id":"4d1e615307d2f682","repo":"Intervention/image","slug":"colorspace","errorCode":null,"errorMessage":"Colorspace ","messagePattern":"Colorspace ","errorType":"exception","errorClass":"Intervention\\Image\\Exceptions\\NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Drivers/Imagick/ColorProcessor.php","lineNumber":141,"sourceCode":"                Hsv::class => Rgb::colorFromNormalized([\n                    $color->getColorValue(Imagick::COLOR_RED),\n                    $color->getColorValue(Imagick::COLOR_GREEN),\n                    $color->getColorValue(Imagick::COLOR_BLUE),\n                    $color->getColorValue(Imagick::COLOR_ALPHA),\n                ])->toColorspace(Hsv::class),\n                Oklab::class => Rgb::colorFromNormalized([\n                    $color->getColorValue(Imagick::COLOR_RED),\n                    $color->getColorValue(Imagick::COLOR_GREEN),\n                    $color->getColorValue(Imagick::COLOR_BLUE),\n                    $color->getColorValue(Imagick::COLOR_ALPHA),\n                ])->toColorspace(Oklab::class),\n                Oklch::class => Rgb::colorFromNormalized([\n                    $color->getColorValue(Imagick::COLOR_RED),\n                    $color->getColorValue(Imagick::COLOR_GREEN),\n                    $color->getColorValue(Imagick::COLOR_BLUE),\n                    $color->getColorValue(Imagick::COLOR_ALPHA),\n                ])->toColorspace(Oklch::class),\n                default => throw new NotSupportedException(\n                    'Colorspace ' . $this->colorspace::class . ' is not supported by driver',\n                )\n            };\n        } catch (ImagickPixelException $e) {\n            throw new DriverException(\n                'Failed to import color from ' . ImagickPixel::class,\n                previous: $e,\n            );\n        }\n    }\n}\n","sourceCodeStart":123,"sourceCodeEnd":153,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/Imagick/ColorProcessor.php#L123-L153","documentation":"import() maps an ImagickPixel into a library color by switching on the colorspace the processor was constructed for; only Cmyk, Rgb, Hsl, Hsv, Oklab and Oklch have branches. If the processor's colorspace is anything else — a custom colorspace class, or one derived from an image whose colorspace does not match the supported set — the default arm throws NotSupportedException rather than guessing.","triggerScenarios":"Constructing a ColorProcessor with a custom/unregistered colorspace class; calling colorProcessor($image)->import($pixel) on an image whose colorspace is outside the supported six (e.g. after a native setImageColorspace to GRAY).","commonSituations":"Extending the library with bespoke colorspaces; hand-built Imagick pipelines that set unusual colorspaces before handing the image back to the library.","solutions":["Keep the image in a supported colorspace before using colorProcessor(): $image->setColorspace(Rgb\\Colorspace::class).","Map custom colorspaces to the nearest built-in at the processor boundary instead of registering them directly.","Catch NotSupportedException and degrade to reading RGB channel values from the pixel manually."],"exampleFix":"// before\n$color = $image->driver()->colorProcessor($image)->import($pixel); // colorspace e.g. grayscale\n\n// after: convert the image to a supported colorspace first\n$image = $image->setColorspace(\\Intervention\\Image\\Colors\\Rgb\\Colorspace::class);\n$color = $image->driver()->colorProcessor($image)->import($pixel);","handlingStrategy":"validation","validationCode":"$supported = [Cmyk\\Colorspace::class, Rgb\\Colorspace::class, Hsl\\Colorspace::class, Hsv\\Colorspace::class, Oklab\\Colorspace::class, Oklch\\Colorspace::class];\n$processor = $image->driver()->colorProcessor($image);\nif (!in_array($processor->colorspace()::class, $supported, true)) {\n    $image = $image->setColorspace(Rgb\\Colorspace::class);\n    $processor = $image->driver()->colorProcessor($image);\n}\n$color = $processor->import($pixel);","typeGuard":null,"tryCatchPattern":"try { $color = $processor->import($pixel); } catch (\\Intervention\\Image\\Exceptions\\NotSupportedException $e) { /* convert image to sRGB, then retry */ }","preventionTips":["Keep images in one of the six supported colorspaces before colorProcessor() calls.","Map custom colorspaces to a built-in at the processor boundary.","Branch on processor->colorspace()::class when integrating custom pipelines."],"tags":["imagick","colorprocessor","colorspace","not-supported"],"backgroundTag":"unsupported-colorspace","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}