{"record":{"id":"27a658423657a5b1","repo":"Intervention/image","slug":"failed-to-apply-intervention-image-drivers-imagick-27a658","errorCode":null,"errorMessage":"Failed to apply Intervention\\Image\\Drivers\\Imagick\\Modifiers\\ContainModifier, unable fill new image areas with replacement color","messagePattern":"Failed to apply Intervention\\\\Image\\\\Drivers\\\\Imagick\\\\Modifiers\\\\ContainModifier, unable fill new image areas with replacement color","errorType":"exception","errorClass":"ModifierException","httpStatus":null,"severity":"error","filePath":"src/Drivers/Imagick/Modifiers/ContainModifier.php","lineNumber":149,"sourceCode":"        SizeInterface $resize,\n        ImagickPixel $background,\n    ): void {\n        try {\n            $draw = new ImagickDraw();\n            $draw->setFillColor($background);\n\n            $delta = abs($crop->pivot()->x());\n\n            if ($delta > 0) {\n                $draw->rectangle(0, 0, $delta - 1, $resize->height());\n            }\n\n            $draw->rectangle($crop->width() + $delta, 0, $resize->width(), $resize->height());\n\n            $result = $native->drawImage($draw);\n\n            if ($result === false) {\n                throw new ModifierException(\n                    'Failed to apply ' . self::class . ', unable fill new image areas with replacement color',\n                );\n            }\n        } catch (ImagickException | ImagickDrawException $e) {\n            throw new ModifierException(\n                'Failed to apply ' . self::class . ', unable fill new image areas with replacement color',\n                previous: $e,\n            );\n        }\n    }\n\n    /**\n     * Fill the top and bottom background areas that emerged after vertical extension.\n     *\n     * @throws ModifierException\n     */\n    private function fillVerticalAreas(\n        Imagick $native,","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/Imagick/Modifiers/ContainModifier.php#L131-L167","documentation":"Error \"Failed to apply Intervention\\Image\\Drivers\\Imagick\\Modifiers\\ContainModifier, unable fill new image areas with replacement color\" thrown in Intervention/image.","triggerScenarios":"Thrown at src/Drivers/Imagick/Modifiers/ContainModifier.php:149 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a valid color value for the background parameter: a CSS color string (e.g. \"ffffff\", \"rgba(255,255,255,0)\"), a ColorInterface instance, or a value the Imagick driver can parse","Check that the Imagick extension can create a new pixel with the given color by testing \\ImagickPixel::setColor with the same value beforehand","Verify the image being contained has positive width and height before applying the modifier"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}