{"record":{"id":"3f91406227166a34","repo":"Intervention/image","slug":"failed-to-read-image-height","errorCode":null,"errorMessage":"Failed to read image height","messagePattern":"Failed to read image height","errorType":"exception","errorClass":"AnalyzerException","httpStatus":null,"severity":"error","filePath":"src/Drivers/Imagick/Analyzers/HeightAnalyzer.php","lineNumber":23,"sourceCode":"namespace Intervention\\Image\\Drivers\\Imagick\\Analyzers;\n\nuse ImagickException;\nuse Intervention\\Image\\Analyzers\\HeightAnalyzer as GenericHeightAnalyzer;\nuse Intervention\\Image\\Exceptions\\AnalyzerException;\nuse Intervention\\Image\\Interfaces\\ImageInterface;\nuse Intervention\\Image\\Interfaces\\SpecializedInterface;\n\nclass HeightAnalyzer extends GenericHeightAnalyzer implements SpecializedInterface\n{\n    /**\n     * @throws AnalyzerException\n     */\n    public function analyze(ImageInterface $image): mixed\n    {\n        try {\n            return $image->core()->native()->getImageHeight();\n        } catch (ImagickException $e) {\n            throw new AnalyzerException('Failed to read image height', previous: $e);\n        }\n    }\n}\n","sourceCodeStart":5,"sourceCodeEnd":27,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/Imagick/Analyzers/HeightAnalyzer.php#L5-L27","documentation":"$image->height() on the Imagick driver is a thin wrapper around Imagick::getImageHeight(); any ImagickException is normalized to this AnalyzerException. On a successfully decoded image the call is essentially infallible, so a failure means the underlying Imagick object is empty or corrupted — the image stack was cleared, the object was reused after a prior error, or its internal state is bad.","triggerScenarios":"Calling height() on an Image whose Imagick container was emptied via clear()/destroy() by custom code; building an Image around a bare new Imagick(); chained operations after an earlier Imagick failure left the object in a broken state.","commonSituations":"Custom code that holds core()->native() and clears or mutates it; long-running workers with stale handles; partially decoded files from failing delegates.","solutions":["Only query dimensions on images produced by a successful $manager->read() call.","After any manual Imagick manipulation, rebuild the library image from the original binary instead of reusing the possibly-broken object.","If it persists, isolate the failing file and inspect it with the imagick identify CLI to confirm corruption."],"exampleFix":"// before\n$height = $image->height(); // $image built around an emptied Imagick object\n\n// after: always start from a successfully decoded source\n$image = $manager->read($binary);\n$height = $image->height();","handlingStrategy":"try-catch","validationCode":"// only query dimensions on images from a successful read\nif (!$image->core()->native() instanceof \\Imagick || $image->core()->count() < 1) {\n    throw new RuntimeException('Image resource is not usable');\n}","typeGuard":null,"tryCatchPattern":"try { $h = $image->height(); } catch (AnalyzerException $e) { /* rebuild from source bytes and retry once */ }","preventionTips":["Never clear()/destroy() the native Imagick of a live library image.","Rebuild images from binary after any manual Imagick surgery.","Treat width()/height() failures as a signal the whole object is suspect."],"tags":["imagick","height","analyzer","imagickexception","invalid-resource"],"backgroundTag":"invalid-image-resource","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}