Intervention/image · error · Intervention\Image\Exceptions\NotSupportedException
Colorspace
Error message
Colorspace
What it means
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.
Source
Thrown at src/Drivers/Imagick/ColorProcessor.php:141
Hsv::class => Rgb::colorFromNormalized([
$color->getColorValue(Imagick::COLOR_RED),
$color->getColorValue(Imagick::COLOR_GREEN),
$color->getColorValue(Imagick::COLOR_BLUE),
$color->getColorValue(Imagick::COLOR_ALPHA),
])->toColorspace(Hsv::class),
Oklab::class => Rgb::colorFromNormalized([
$color->getColorValue(Imagick::COLOR_RED),
$color->getColorValue(Imagick::COLOR_GREEN),
$color->getColorValue(Imagick::COLOR_BLUE),
$color->getColorValue(Imagick::COLOR_ALPHA),
])->toColorspace(Oklab::class),
Oklch::class => Rgb::colorFromNormalized([
$color->getColorValue(Imagick::COLOR_RED),
$color->getColorValue(Imagick::COLOR_GREEN),
$color->getColorValue(Imagick::COLOR_BLUE),
$color->getColorValue(Imagick::COLOR_ALPHA),
])->toColorspace(Oklch::class),
default => throw new NotSupportedException(
'Colorspace ' . $this->colorspace::class . ' is not supported by driver',
)
};
} catch (ImagickPixelException $e) {
throw new DriverException(
'Failed to import color from ' . ImagickPixel::class,
previous: $e,
);
}
}
}
View on GitHub (pinned to 5598b9e397)
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.
Example fix
// before $color = $image->driver()->colorProcessor($image)->import($pixel); // colorspace e.g. grayscale // after: convert the image to a supported colorspace first $image = $image->setColorspace(\Intervention\Image\Colors\Rgb\Colorspace::class); $color = $image->driver()->colorProcessor($image)->import($pixel);
Defensive patterns
Strategy: validation
Validate before calling
$supported = [Cmyk\Colorspace::class, Rgb\Colorspace::class, Hsl\Colorspace::class, Hsv\Colorspace::class, Oklab\Colorspace::class, Oklch\Colorspace::class];
$processor = $image->driver()->colorProcessor($image);
if (!in_array($processor->colorspace()::class, $supported, true)) {
$image = $image->setColorspace(Rgb\Colorspace::class);
$processor = $image->driver()->colorProcessor($image);
}
$color = $processor->import($pixel); Try / catch
try { $color = $processor->import($pixel); } catch (\Intervention\Image\Exceptions\NotSupportedException $e) { /* convert image to sRGB, then retry */ } Prevention
- 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.
When it happens
Trigger: 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).
Common situations: Extending the library with bespoke colorspaces; hand-built Imagick pipelines that set unusual colorspaces before handing the image back to the library.
Related errors
- Failed to analyze unknown colorspace
- Failed to analyze colorspace
- Imagick driver can only process colors from instances of
- Failed to import color from
- Failed to convert image to sRGB
AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23).
Data as JSON: /api/errors/4d1e615307d2f682.
Report an issue: GitHub.