{"record":{"id":"85ec7e0dff19b81a","repo":"Intervention/image","slug":"failed-to-apply-intervention-image-drivers-imagick-85ec7e","errorCode":null,"errorMessage":"Failed to apply Intervention\\Image\\Drivers\\Imagick\\Modifiers\\FillModifier, unable to flood fill image","messagePattern":"Failed to apply Intervention\\\\Image\\\\Drivers\\\\Imagick\\\\Modifiers\\\\FillModifier, unable to flood fill image","errorType":"exception","errorClass":"ModifierException","httpStatus":null,"severity":"error","filePath":"src/Drivers/Imagick/Modifiers/FillModifier.php","lineNumber":73,"sourceCode":"            throw new ModifierException(\n                'Failed to apply ' . self::class . ', unable to find target flood fill color',\n                previous: $e,\n            );\n        }\n\n        try {\n            $result = $frame->floodFillPaintImage(\n                $pixel,\n                100,\n                $target,\n                $this->position->x(),\n                $this->position->y(),\n                false,\n                Imagick::CHANNEL_ALL,\n            );\n\n            if ($result === false) {\n                throw new ModifierException(\n                    'Failed to apply ' . self::class . ', unable to flood fill image',\n                );\n            }\n        } catch (ImagickException $e) {\n            throw new ModifierException(\n                'Failed to apply ' . self::class . ', unable to flood fill image',\n                previous: $e,\n            );\n        }\n    }\n\n    /**\n     * @throws ModifierException\n     */\n    private function fillAllWithColor(Imagick $frame, ImagickPixel $pixel): void\n    {\n        try {\n            $draw = new ImagickDraw();","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/Imagick/Modifiers/FillModifier.php#L55-L91","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Check ImageMagick resource limits with `convert -list resource` or `magick -list resource` and the policy.xml file","Raise the area/memory limits in /etc/ImageMagick-*/policy.xml (or ask the hoster to)","Test the same fill on a small downscaled copy to confirm a resource-limit cause","Update the imagick PHP extension and ImageMagick to current stable versions","As a workaround for restrictive hosts, process with the GD driver instead"],"exampleFix":"// before\n$image = $manager->read($hugePath);\n$image->fill('ffffff', 10, 10); // false from floodFillPaintImage on 50MP image\n\n// after (limit-aware)\n$image = $manager->read($hugePath);\nif ($image->width() * $image->height() > 30_000_000) {\n    $image->scaleDown(width: 4000);\n}\n$image->fill('ffffff', 10, 10);","handlingStrategy":"try-catch","validationCode":"$pixelCount = $image->width() * $image->height();\nif ($pixelCount > 40_000_000) { // adjust to your policy.xml area limit\n    $image->scaleDown(width: (int) sqrt(40_000_000 * $image->width() / $image->height()));\n}\n$image->fill($color, $x, $y);","typeGuard":null,"tryCatchPattern":"use Intervention\\Image\\Exceptions\\ModifierException;\n\ntry {\n    $image->fill($color, $x, $y);\n} catch (ModifierException $e) {\n    Log::warning('Flood fill failed: ' . optional($e->getPrevious())->getMessage());\n    // fall back to full fill without seed position\n    $image->fill($color);\n}","preventionTips":["Know your ImageMagick limits: run `magick -list resource` on the target host","Downscale very large images before positional fills","Raise policy.xml area/memory limits if you legitimately process huge images","Wrap fills in try-catch with a full-fill fallback when the seed is optional"],"tags":["intervention-image","imagick","flood-fill","resource-limits","policy-xml","php"],"backgroundTag":"imagick-flood-fill-failed","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}