Intervention/image · error · ModifierException

Failed to apply Intervention\Image\Drivers\Imagick\Modifiers

Error message

Failed to apply Intervention\Image\Drivers\Imagick\Modifiers\FillModifier, unable to flood fill image

What it means

This ModifierException is thrown when a positional fill fails during the actual paint operation: Imagick's floodFillPaintImage() returned false instead of the expected true. The driver calls it with the fill color, the sampled target pixel, your coordinates and CHANNEL_ALL; a false return means ImageMagick refused or could not execute the flood fill on this image in this environment.

Source

Thrown at src/Drivers/Imagick/Modifiers/FillModifier.php:73

            throw new ModifierException(
                'Failed to apply ' . self::class . ', unable to find target flood fill color',
                previous: $e,
            );
        }

        try {
            $result = $frame->floodFillPaintImage(
                $pixel,
                100,
                $target,
                $this->position->x(),
                $this->position->y(),
                false,
                Imagick::CHANNEL_ALL,
            );

            if ($result === false) {
                throw new ModifierException(
                    'Failed to apply ' . self::class . ', unable to flood fill image',
                );
            }
        } catch (ImagickException $e) {
            throw new ModifierException(
                'Failed to apply ' . self::class . ', unable to flood fill image',
                previous: $e,
            );
        }
    }

    /**
     * @throws ModifierException
     */
    private function fillAllWithColor(Imagick $frame, ImagickPixel $pixel): void
    {
        try {
            $draw = new ImagickDraw();

View on GitHub (pinned to 5598b9e397)

Solutions

  1. Check ImageMagick resource limits with `convert -list resource` or `magick -list resource` and the policy.xml file
  2. Raise the area/memory limits in /etc/ImageMagick-*/policy.xml (or ask the hoster to)
  3. Test the same fill on a small downscaled copy to confirm a resource-limit cause
  4. Update the imagick PHP extension and ImageMagick to current stable versions
  5. As a workaround for restrictive hosts, process with the GD driver instead

Example fix

// before
$image = $manager->read($hugePath);
$image->fill('ffffff', 10, 10); // false from floodFillPaintImage on 50MP image

// after (limit-aware)
$image = $manager->read($hugePath);
if ($image->width() * $image->height() > 30_000_000) {
    $image->scaleDown(width: 4000);
}
$image->fill('ffffff', 10, 10);
Defensive patterns

Strategy: try-catch

Validate before calling

$pixelCount = $image->width() * $image->height();
if ($pixelCount > 40_000_000) { // adjust to your policy.xml area limit
    $image->scaleDown(width: (int) sqrt(40_000_000 * $image->width() / $image->height()));
}
$image->fill($color, $x, $y);

Try / catch

use Intervention\Image\Exceptions\ModifierException;

try {
    $image->fill($color, $x, $y);
} catch (ModifierException $e) {
    Log::warning('Flood fill failed: ' . optional($e->getPrevious())->getMessage());
    // fall back to full fill without seed position
    $image->fill($color);
}

Prevention

When it happens

Trigger: Calling $image->fill($color, $x, $y) on a very large image whose pixel cache exceeds ImageMagick's configured area/memory resource limits; fills on images in colorspaces or formats where the paint operation is unsupported by the installed ImageMagick build; environments whose policy.xml restricts memory or operations; degraded imagick extension installs (partial ImageMagick delegates).

Common situations: Batch-processing user uploads on shared hosting with tight ImageMagick resource policies; filling high-resolution photos (e.g. 8000x6000) where the single-row pixel cache is fine but the paint crosses the area limit; Docker images built with a minimal ImageMagick that lacks full delegate support; behavior differences after an ImageMagick 6 to 7 upgrade.

Related errors


AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23). Data as JSON: /api/errors/85ec7e0dff19b81a. Report an issue: GitHub.