{"record":{"id":"4cd1a4232d0be419","repo":"Intervention/image","slug":"failed-to-apply-intervention-image-drivers-imagick-4cd1a4","errorCode":null,"errorMessage":"Failed to apply Intervention\\Image\\Drivers\\Imagick\\Modifiers\\ContrastModifier, unable to adjust image contrast","messagePattern":"Failed to apply Intervention\\\\Image\\\\Drivers\\\\Imagick\\\\Modifiers\\\\ContrastModifier, unable to adjust image contrast","errorType":"exception","errorClass":"ModifierException","httpStatus":null,"severity":"error","filePath":"src/Drivers/Imagick/Modifiers/ContrastModifier.php","lineNumber":33,"sourceCode":"{\n    /**\n     * @throws ModifierException\n     */\n    public function apply(ImageInterface $image): ImageInterface\n    {\n        // sigmoidalContrastImage's midpoint argument is in QuantumRange units,\n        // not the [0..1] range a normalized API would imply. Passing 0 pivots\n        // the sigmoidal curve around pure black, which lifts every pixel\n        // including the midtone — the opposite of a symmetric contrast\n        // adjustment. Pivot around the middle of the QuantumRange so a\n        // mid-grey pixel survives unchanged and the curve is symmetric.\n        $midpoint = Imagick::QUANTUM_RANGE / 2;\n\n        foreach ($image as $frame) {\n            try {\n                $result = $frame->native()->sigmoidalContrastImage($this->level > 0, abs($this->level / 4), $midpoint);\n                if ($result === false) {\n                    throw new ModifierException(\n                        'Failed to apply ' . self::class . ', unable to adjust image contrast',\n                    );\n                }\n            } catch (ImagickException $e) {\n                throw new ModifierException(\n                    'Failed to apply ' . self::class . ', unable to adjust image contrast',\n                    previous: $e,\n                );\n            }\n        }\n\n        return $image;\n    }\n}\n","sourceCodeStart":15,"sourceCodeEnd":48,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/Imagick/Modifiers/ContrastModifier.php#L15-L48","documentation":"Error \"Failed to apply Intervention\\Image\\Drivers\\Imagick\\Modifiers\\ContrastModifier, unable to adjust image contrast\" thrown in Intervention/image.","triggerScenarios":"Thrown at src/Drivers/Imagick/Modifiers/ContrastModifier.php:33 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a contrast level as an integer between -100 and 100","Make sure the image was successfully decoded before calling contrast(), since the modifier operates on every frame of the Imagick instance","Verify the Imagick extension is installed and its version supports contrastImage"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}