{"record":{"id":"da2b6f10f8849613","repo":"Intervention/image","slug":"failed-to-apply-intervention-image-drivers-imagick-da2b6f","errorCode":null,"errorMessage":"Failed to apply Intervention\\Image\\Drivers\\Imagick\\Modifiers\\BrightnessModifier, unable to adjust image brightness","messagePattern":"Failed to apply Intervention\\\\Image\\\\Drivers\\\\Imagick\\\\Modifiers\\\\BrightnessModifier, unable to adjust image brightness","errorType":"exception","errorClass":"ModifierException","httpStatus":null,"severity":"error","filePath":"src/Drivers/Imagick/Modifiers/BrightnessModifier.php","lineNumber":24,"sourceCode":"\nuse ImagickException;\nuse Intervention\\Image\\Exceptions\\ModifierException;\nuse Intervention\\Image\\Interfaces\\ImageInterface;\nuse Intervention\\Image\\Interfaces\\SpecializedInterface;\nuse Intervention\\Image\\Modifiers\\BrightnessModifier as GenericBrightnessModifier;\n\nclass BrightnessModifier extends GenericBrightnessModifier implements SpecializedInterface\n{\n    /**\n     * @throws ModifierException\n     */\n    public function apply(ImageInterface $image): ImageInterface\n    {\n        foreach ($image as $frame) {\n            try {\n                $result = $frame->native()->modulateImage(100 + $this->level, 100, 100);\n                if ($result === false) {\n                    throw new ModifierException(\n                        'Failed to apply ' . self::class . ', unable to adjust image brightness',\n                    );\n                }\n            } catch (ImagickException $e) {\n                throw new ModifierException(\n                    'Failed to apply ' . self::class . ', unable to adjust image brightness',\n                    previous: $e,\n                );\n            }\n        }\n\n        return $image;\n    }\n}\n","sourceCodeStart":6,"sourceCodeEnd":39,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/Imagick/Modifiers/BrightnessModifier.php#L6-L39","documentation":"Thrown by the Imagick BrightnessModifier when Imagick::modulateImage(100 + level, 100, 100) returns false during $image->brightness($level). The modifier maps brightness percentage onto modulateImage's first argument; a false return means ImageMagick refused the operation without throwing. No previous exception is attached to this variant.","triggerScenarios":"Calling $image->brightness() with any level (positive or negative — the constructor does not restrict it) on a frame where modulateImage cannot run: degraded wand state, unsupported image type for modulation, or resource exhaustion.","commonSituations":"Applying brightness adjustments to CMYK or grayscale-source images on ImageMagick versions with incomplete modulate support; batch pipelines on hosts with tight policy.xml limits; reusing images after failed prior operations.","solutions":["Check $e->getPrevious() chain and, if absent (false-return path), reproduce via CLI: convert in.png -modulate 130x100x100 out.png to see the environment error.","Convert the working image to sRGB before brightness: read with the Imagick driver and apply colorspace(RgbColorspace) first.","Raise ImageMagick resource limits or process a downscaled copy when dimensions are extreme.","Update ImageMagick/ext-imagick to matching current versions if modulate fails for ordinary RGB inputs."],"exampleFix":"// before\n$image->brightness(30); // false-return -> ModifierException\n\n// after\n$image->colorspace(\\Intervention\\Image\\Colors\\Rgb\\Colorspace::class)->brightness(30);","handlingStrategy":"fallback","validationCode":"// probe modulate support for this build before relying on brightness()\n$probe = new \\Imagick();\n$probe->newImage(4, 4, new \\ImagickPixel('gray'));\n$modulateOk = $probe->modulateImage(120, 100, 100) !== false;\n$probe->destroy();","typeGuard":null,"tryCatchPattern":"use Intervention\\Image\\Exceptions\\ModifierException;\ntry {\n    $image->brightness(25);\n} catch (ModifierException $e) {\n    // fallback path: convert to sRGB and retry once\n    try {\n        $image->colorspace(\\Intervention\\Image\\Colors\\Rgb\\Colorspace::class)->brightness(25);\n    } catch (ModifierException $e2) {\n        throw $e2;\n    }\n}","preventionTips":["Normalize inputs to sRGB before brightness adjustments, especially CMYK sources.","Keep brightness levels in the documented -100..100 spirit; extreme values amplify resource use."],"tags":["imagick","brightness","filter","modifier-exception","colourspace"],"backgroundTag":"image-modifier-failed","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}