{"record":{"id":"4bcc2d08be10fc53","repo":"Intervention/image","slug":"invalid-color-limit-must-be-int-1-max","errorCode":null,"errorMessage":"Invalid color limit. Must be int<1, max>","messagePattern":"Invalid color limit\\. Must be int<1, max>","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Modifiers/ReduceColorsModifier.php","lineNumber":25,"sourceCode":"use Intervention\\Image\\Drivers\\SpecializableModifier;\nuse Intervention\\Image\\Exceptions\\InvalidArgumentException;\nuse Intervention\\Image\\Exceptions\\StateException;\nuse Intervention\\Image\\Interfaces\\ColorInterface;\nuse Intervention\\Image\\Interfaces\\ImageInterface;\n\nclass ReduceColorsModifier extends SpecializableModifier\n{\n    /**\n     * Create new modifier object.\n     *\n     * @throws InvalidArgumentException\n     */\n    public function __construct(\n        public int $limit,\n        public null|string|ColorInterface $background = null,\n    ) {\n        if ($this->limit < 1) {\n            throw new InvalidArgumentException('Invalid color limit. Must be int<1, max>');\n        }\n    }\n\n    /**\n     * Return the color in the image's colorspace to fill transparent areas.\n     *\n     * @throws StateException\n     */\n    protected function backgroundColor(ImageInterface $image): ColorInterface\n    {\n        return $this->driver()->decodeColor(\n            $this->background ?? $this->driver()->config()->backgroundColor,\n        )->toColorspace($image->colorspace());\n    }\n}\n","sourceCodeStart":7,"sourceCodeEnd":41,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Modifiers/ReduceColorsModifier.php#L7-L41","documentation":"Error \"Invalid color limit. Must be int<1, max>\" thrown in Intervention/image.","triggerScenarios":"Thrown at src/Modifiers/ReduceColorsModifier.php:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a color limit of at least 1 to reduceColors()","Clamp computed limits: max(1, (int) $limit)","Note practical upper bounds depend on the driver; keep limits within a sane range (1-255)"],"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"}