{"record":{"id":"97262d8c170334e9","repo":"Intervention/image","slug":"given-color-space-must-implement-intervention-imag","errorCode":null,"errorMessage":"Given color space must implement Intervention\\Image\\Interfaces\\ColorspaceInterface","messagePattern":"Given color space must implement Intervention\\\\Image\\\\Interfaces\\\\ColorspaceInterface","errorType":"exception","errorClass":"Intervention\\Image\\Exceptions\\InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Colors/AbstractColor.php","lineNumber":79,"sourceCode":"    }\n\n    /**\n     * {@inheritdoc}\n     *\n     * @see ColorInterface::toColorspace()\n     *\n     * @throws InvalidArgumentException\n     */\n    public function toColorspace(string|ColorspaceInterface $colorspace): ColorInterface\n    {\n        if (is_string($colorspace) && !class_exists($colorspace)) {\n            throw new InvalidArgumentException('Unknown color space (' . $colorspace . ') as conversion target');\n        }\n\n        $colorspace = is_string($colorspace) ? new $colorspace() : $colorspace;\n\n        if (!$colorspace instanceof ColorspaceInterface) {\n            throw new InvalidArgumentException('Given color space must implement ' . ColorspaceInterface::class);\n        }\n\n        return $colorspace->importColor($this);\n    }\n\n    /**\n     * {@inheritdoc}\n     *\n     * @see ColorInterface::isTransparent()\n     */\n    public function isTransparent(): bool\n    {\n        return $this->alpha()->value() < $this->alpha()->max();\n    }\n\n    /**\n     * {@inheritdoc}\n     *","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Colors/AbstractColor.php#L61-L97","documentation":"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.","triggerScenarios":"$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.","commonSituations":"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.","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"],"exampleFix":"// before (throws \\Exception on Imagick driver)\n$image->core()->filter(fn ($frame) => $frame->native()->rotateImage(new \\ImagickPixel(), 5));\n\n// after: iterate frames manually on Imagick\nforeach ($image as $frame) {\n    $frame->native()->rotateImage(new \\ImagickPixel(), 5);\n}","handlingStrategy":"fallback","validationCode":"use Intervention\\Image\\Drivers\\Imagick\\Driver as ImagickDriver;\n\nif ($image->driver() instanceof ImagickDriver) {\n    // core()->filter() is not implemented on Imagick: use the frame loop below\n    foreach ($image as $frame) {\n        $callback($frame);\n    }\n} else {\n    $image->core()->filter($callback);\n}","typeGuard":"use Intervention\\Image\\Drivers\\Imagick\\Driver as ImagickDriver;\n\nfunction coreFilterAvailable(\\Intervention\\Image\\Image $image): bool\n{\n    return !$image->driver() instanceof ImagickDriver;\n}","tryCatchPattern":"try {\n    $image->core()->filter($callback);\n} catch (\\Exception $e) {\n    if ($e->getMessage() === 'Not implemented') {\n        // Imagick driver stub: fall back to a manual frame loop\n        foreach ($image as $frame) {\n            $callback($frame);\n        }\n    } else {\n        throw $e;\n    }\n}","preventionTips":["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"],"tags":["imagick","not-implemented","core","frames","driver-specific","intervention-image"],"backgroundTag":"method-not-implemented","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}