{"record":{"id":"f779140a8fc22e88","repo":"Intervention/image","slug":"failed-to-resize-image","errorCode":null,"errorMessage":"Failed to resize image","messagePattern":"Failed to resize image","errorType":"exception","errorClass":"Intervention\\Image\\Exceptions\\ModifierException","httpStatus":null,"severity":"error","filePath":"src/Image.php","lineNumber":707,"sourceCode":"                FontFactory::build($font),\n            ),\n        );\n    }\n\n    /**\n     * {@inheritdoc}\n     *\n     * @see ImageInterface::resize()\n     *\n     * @throws InvalidArgumentException\n     * @throws ModifierException\n     */\n    public function resize(null|int|Fraction $width = null, null|int|Fraction $height = null): ImageInterface\n    {\n        try {\n            return $this->modify(new ResizeModifier(...$this->resolveDimension($width, $height)));\n        } catch (AnalyzerException $e) {\n            throw new ModifierException('Failed to resize image', previous: $e);\n        }\n    }\n\n    /**\n     * {@inheritdoc}\n     *\n     * @see ImageInterface::resizeDown()\n     *\n     * @throws InvalidArgumentException\n     * @throws ModifierException\n     */\n    public function resizeDown(null|int|Fraction $width = null, null|int|Fraction $height = null): ImageInterface\n    {\n        try {\n            return $this->modify(new ResizeDownModifier(...$this->resolveDimension($width, $height)));\n        } catch (AnalyzerException $e) {\n            throw new ModifierException('Failed to resize image', previous: $e);\n        }","sourceCodeStart":689,"sourceCodeEnd":725,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Image.php#L689-L725","documentation":"Image::resize() wraps dimension resolution and the ResizeModifier in a try/catch that converts any AnalyzerException into ModifierException('Failed to resize image'). The analyzer call happens in resolveDimension(): when width or height is a Fraction enum (e.g. Fraction::HALF), it must read the current image size via size() — if that analysis fails, the error is wrapped here with the original exception as previous. Plain invalid ints (like both null) throw a different, unwrapped InvalidArgumentException from ResizeModifier.","triggerScenarios":"$image->resize(Fraction::HALF, null) (or any Fraction argument) on an image whose width()/height() analysis or Size construction fails; see the size() entry for how that happens. resize(300, 200) with plain ints does not reach the analyzer and cannot produce this message.","commonSituations":"Percentage-style resizing (Fraction enums) applied to corrupted or inconsistent image cores, chained operations after a partially failed decode, or images from a problematic source file. The wrapper obscures the root cause, so developers see 'Failed to resize image' without the underlying analyzer error.","solutions":["Read $e->getPrevious() — the original AnalyzerException tells you what actually failed","If using Fraction arguments, verify $image->width() and $image->height() succeed before resizing","Re-read the image from its original source; discard objects with inconsistent state","Convert relative sizes to absolute ints yourself (compute from $image->size()) to bypass the analyzer path"],"exampleFix":"// before\n$image->resize(Fraction::HALF, null); // ModifierException if size analysis fails\n\n// after\n$size = $image->size(); // fail early, clear error\n$image->resize((int) round($size->width() / 2), null);","handlingStrategy":"try-catch","validationCode":"try {\n    $size = $image->size();\n} catch (AnalyzerException) {\n    return reject('source image dimensions unreadable');\n}\n// only now use resize(), optionally with Fraction","typeGuard":"function canResolveFractions(ImageInterface $image): bool\n{\n    try { $image->size(); return true; }\n    catch (\\Throwable) { return false; }\n}","tryCatchPattern":"try {\n    $image->resize(Fraction::HALF);\n} catch (ModifierException $e) {\n    $cause = $e->getPrevious(); // AnalyzerException with the real failure\n}","preventionTips":["Verify size() before Fraction-based resizing","Compute absolute ints from a verified size to skip the analyzer path","In pipelines, catch per-image and quarantine rather than aborting the batch"],"tags":["resize","modifier","analyzer","fraction"],"backgroundTag":"image-resize-failed","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}