Intervention/image · error · ModifierException
Failed to apply Intervention\Image\Drivers\Imagick\Modifiers
Error message
Failed to apply Intervention\Image\Drivers\Imagick\Modifiers\ContainModifier, unable fill new image areas with replacement color
What it means
Error "Failed to apply Intervention\Image\Drivers\Imagick\Modifiers\ContainModifier, unable fill new image areas with replacement color" thrown in Intervention/image.
Source
Thrown at src/Drivers/Imagick/Modifiers/ContainModifier.php:149
SizeInterface $resize,
ImagickPixel $background,
): void {
try {
$draw = new ImagickDraw();
$draw->setFillColor($background);
$delta = abs($crop->pivot()->x());
if ($delta > 0) {
$draw->rectangle(0, 0, $delta - 1, $resize->height());
}
$draw->rectangle($crop->width() + $delta, 0, $resize->width(), $resize->height());
$result = $native->drawImage($draw);
if ($result === false) {
throw new ModifierException(
'Failed to apply ' . self::class . ', unable fill new image areas with replacement color',
);
}
} catch (ImagickException | ImagickDrawException $e) {
throw new ModifierException(
'Failed to apply ' . self::class . ', unable fill new image areas with replacement color',
previous: $e,
);
}
}
/**
* Fill the top and bottom background areas that emerged after vertical extension.
*
* @throws ModifierException
*/
private function fillVerticalAreas(
Imagick $native,View on GitHub (pinned to 5598b9e397)
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
When it happens
Trigger: Thrown at src/Drivers/Imagick/Modifiers/ContainModifier.php:149 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23).
Data as JSON: /api/errors/27a658423657a5b1.
Report an issue: GitHub.