Intervention/image · error · Intervention\Image\Exceptions\InvalidArgumentException
Given color space must implement Intervention\Image\Interfac
Error message
Given color space must implement Intervention\Image\Interfaces\ColorspaceInterface
What it means
The Imagick driver's Core::filter() — the per-frame callback filter on the image core — is a stub that unconditionally throws new \Exception('Not implemented'). Unlike Core::map(), which throws NotSupportedException, this method throws a plain global \Exception, so it is not distinguishable by exception type. You hit it by calling $image->core()->filter($callback) on any image whose manager was built with the Imagick driver.
Source
Thrown at src/Colors/AbstractColor.php:79
}
/**
* {@inheritdoc}
*
* @see ColorInterface::toColorspace()
*
* @throws InvalidArgumentException
*/
public function toColorspace(string|ColorspaceInterface $colorspace): ColorInterface
{
if (is_string($colorspace) && !class_exists($colorspace)) {
throw new InvalidArgumentException('Unknown color space (' . $colorspace . ') as conversion target');
}
$colorspace = is_string($colorspace) ? new $colorspace() : $colorspace;
if (!$colorspace instanceof ColorspaceInterface) {
throw new InvalidArgumentException('Given color space must implement ' . ColorspaceInterface::class);
}
return $colorspace->importColor($this);
}
/**
* {@inheritdoc}
*
* @see ColorInterface::isTransparent()
*/
public function isTransparent(): bool
{
return $this->alpha()->value() < $this->alpha()->max();
}
/**
* {@inheritdoc}
*View on GitHub (pinned to 5598b9e397)
Solutions
- Do not call core()->filter() on the Imagick driver: loop the frames yourself and apply Imagick operations on $frame->native()
- Branch on the driver: if ($image->driver() instanceof \Intervention\Image\Drivers\Imagick\Driver) { /* manual loop */ }
- Run the affected pipeline with the GD driver (new ImageManager(['driver' => GdDriver::class])) if the operation is more important than Imagick features
- If you maintain this code, upstream the fix: implement the filter loop over frames instead of throwing
Example fix
// before (throws \Exception on Imagick driver)
$image->core()->filter(fn ($frame) => $frame->native()->rotateImage(new \ImagickPixel(), 5));
// after: iterate frames manually on Imagick
foreach ($image as $frame) {
$frame->native()->rotateImage(new \ImagickPixel(), 5);
} Defensive patterns
Strategy: fallback
Validate before calling
use Intervention\Image\Drivers\Imagick\Driver as ImagickDriver;
if ($image->driver() instanceof ImagickDriver) {
// core()->filter() is not implemented on Imagick: use the frame loop below
foreach ($image as $frame) {
$callback($frame);
}
} else {
$image->core()->filter($callback);
} Type guard
use Intervention\Image\Drivers\Imagick\Driver as ImagickDriver;
function coreFilterAvailable(\Intervention\Image\Image $image): bool
{
return !$image->driver() instanceof ImagickDriver;
} Try / catch
try {
$image->core()->filter($callback);
} catch (\Exception $e) {
if ($e->getMessage() === 'Not implemented') {
// Imagick driver stub: fall back to a manual frame loop
foreach ($image as $frame) {
$callback($frame);
}
} else {
throw $e;
}
} Prevention
- Wrap driver-specific core operations behind your own interface with a per-driver implementation
- Run your test suite under both drivers (GD and Imagick) in CI so unimplemented paths fail early
- Prefer the documented public API (image-level modifiers) over core()->filter()/map() which are driver-dependent
When it happens
Trigger: $image->core()->filter(fn ($frame) => ...) with an Imagick-driver image; shared code that calls core()->filter() and works under the GD driver but throws under Imagick; animation processing code ported from a GD pipeline.
Common situations: Apps that let the user pick the driver (GD locally, Imagick in production) and only test one path; generic frame-manipulation utilities assumed to be driver-agnostic; upgrading pipelines that previously only used GD.
Related errors
- Not implemented
- Failed to get current frame data
- Failed to slice image
- Failed to apply {class}, unable to re-apply image frame
- Failed to add image frame
AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23).
Data as JSON: /api/errors/97262d8c170334e9.
Report an issue: GitHub.