Intervention/image · error · ModifierException
Failed to apply ' . self::class . ', unable to draw pixel on
Error message
Failed to apply ' . self::class . ', unable to draw pixel on image
What it means
ModifierException from the Imagick CanDraw trait, false-return variant: Imagick::drawImage($element) returned false while rendering a shape, so nothing was drawn. The trait is shared by DrawPixelModifier, DrawLineModifier, DrawPolygonModifier, DrawBezierModifier, DrawEllipseModifier and DrawRectangleModifier, so every shape-drawing API funnels through this single check.
Source
Thrown at src/Drivers/Imagick/Traits/CanDraw.php:25
use Imagick;
use ImagickDraw;
use ImagickException;
use Intervention\Image\Exceptions\ModifierException;
trait CanDraw
{
/**
* Draw given element on canvas.
*
* @throws ModifierException
*/
protected function draw(Imagick $canvas, ImagickDraw $element): void
{
try {
$result = $canvas->drawImage($element);
if ($result === false) {
throw new ModifierException(
'Failed to apply ' . self::class . ', unable to draw pixel on image',
);
}
} catch (ImagickException $e) {
throw new ModifierException(
'Failed to apply ' . self::class . ', unable to draw pixel on image',
previous: $e,
);
}
}
}
View on GitHub (pinned to 5598b9e397)
Solutions
- Verify the target image decodes or is created properly and has pixel data before drawing
- Simplify the shape configuration (plain opaque colors, simple coordinates) to find the rejected property
- Reproduce with a raw Imagick script calling drawImage() on the same element
- Catch ModifierException and log the shape parameters plus getPrevious() for diagnosis
Example fix
// before
$image->drawRectangle(function ($rectangle) {
$rectangle->background('rgba(255, 0, 0, 0)'); // drawImage() returns false
});
// after
$image->drawRectangle(function ($rectangle) {
$rectangle->background('#ff0000');
}); Defensive patterns
Strategy: try-catch
Validate before calling
// draw only on images that hold pixel data
if ($image->count() === 0 || $image->width() < 1 || $image->height() < 1) {
throw new InvalidArgumentException('Canvas has no pixel data to draw on');
} Try / catch
use Intervention\Image\Exceptions\ModifierException;
try {
$image->drawRectangle($callback);
} catch (ModifierException $e) {
$logger->warning('Shape draw returned failure: ' . $e->getMessage());
// overlays are often optional - continue without the shape if acceptable
} Prevention
- Create canvases via the driver's create() helpers so frames always have pixel data
- Use plain opaque hex colors for shape backgrounds and borders
- Draw overlays early on a freshly decoded/created image
When it happens
Trigger: $image->drawRectangle(...), drawEllipse(), drawLine(), drawPolygon(), drawBezier() or a pixel draw on the Imagick driver when drawImage() returns false - typically because the ImagickDraw element is in an unusable state (bad font/color setup, invalid primitive) or the canvas frame is invalid.
Common situations: Drawing shapes on blank/programmatically created images whose frame native object is incomplete; draw elements configured with values some ImageMagick builds reject; reusing an image after an earlier modifier failure.
Related errors
- Color channel {class} value must be in range {min} to {max}
- Class '{objectShortname}' is not supported by {id} driver
- Failed to apply Intervention\Image\Drivers\Imagick\Modifiers
- Failed to apply Intervention\Image\Drivers\Imagick\Modifiers
- Failed to apply {class}, unable to process unsharp mask
AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23).
Data as JSON: /api/errors/d2558da4c552587e.
Report an issue: GitHub.