{"record":{"id":"da1fd7bda3e362fd","repo":"Intervention/image","slug":"failed-to-get-current-frame-data","errorCode":null,"errorMessage":"Failed to get current frame data","messagePattern":"Failed to get current frame data","errorType":"exception","errorClass":"Intervention\\Image\\Exceptions\\DriverException","httpStatus":null,"severity":"error","filePath":"src/Drivers/Imagick/Core.php","lineNumber":105,"sourceCode":"    /**\n     * {@inheritdoc}\n     *\n     * @see CollectionInterface::get()\n     *\n     * @throws DriverException\n     */\n    public function get(int|string $key, mixed $default = null): mixed\n    {\n        try {\n            $this->imagick->setIteratorIndex((int) $key);\n        } catch (ImagickException) {\n            return $default;\n        }\n\n        try {\n            return new Frame($this->imagick->current());\n        } catch (ImagickException | RuntimeException $e) {\n            throw new DriverException('Failed to get current frame data', previous: $e);\n        }\n    }\n\n    /**\n     * {@inheritdoc}\n     *\n     * @see CollectionInterface::set()\n     *\n     * @throws DriverException\n     */\n    public function set(int|string $key, mixed $item): CollectionInterface\n    {\n        return $this->add($item);\n    }\n\n    /**\n     * {@inheritdoc}\n     *","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/Imagick/Core.php#L87-L123","documentation":"Core::get() (reached via at()) first calls setIteratorIndex($key); if that fails it quietly returns $default. Only when the index sets but Imagick::current() then throws does this DriverException fire — meaning the frame container acknowledges the index yet cannot materialize the current frame. That indicates an internally inconsistent or corrupted image list inside Imagick.","triggerScenarios":"at()/get() on a GIF whose frame list is internally inconsistent (corrupt file); calling get() after manual Imagick list surgery (removeImage/addImage) left the iterator between valid states; per-frame lazy decode failing only for the requested frame.","commonSituations":"Animated GIF processing after custom frame manipulation; partially written multi-frame files from interrupted uploads; cores mutated by both raw Imagick calls and the library.","solutions":["Guard the access with the container's own check: $image->core()->has($key) or count() > $key before at().","Re-read the image from the original bytes and retry once; persistent failure marks the file as corrupt.","Avoid mixing raw removeImage()/addImage() calls with the Core API — rebuild the image instead."],"exampleFix":"// before\n$frame = $image->core()->at(2);\n\n// after\n$frame = $image->core()->has(2)\n    ? $image->core()->at(2)\n    : $image->core()->first(); // or handle the missing-frame case explicitly","handlingStrategy":"validation","validationCode":"// guard frame access with the container's own capability check\n$core = $image->core();\n$frame = $core->has($index) ? $core->at($index) : $core->first();","typeGuard":null,"tryCatchPattern":"try { $frame = $image->core()->at($index); } catch (DriverException $e) { /* inconsistent frame list: re-read from original bytes and retry once */ }","preventionTips":["Check has()/count() before at()/get() on frame collections.","Do not mix raw removeImage()/addImage() with the Core API.","Re-read animated files from source after frame-level surgery."],"tags":["imagick","core","frames","gif","invalid-resource"],"backgroundTag":"corrupt-image-data","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}