{"record":{"id":"054a3c5d2a4e9de9","repo":"Intervention/image","slug":"unable-to-parse-cmyk-color-from-input-input","errorCode":null,"errorMessage":"Unable to parse CMYK color from input \"{input}\"","messagePattern":"Unable to parse CMYK color from input \"(.+?)\"","errorType":"exception","errorClass":"Intervention\\Image\\Exceptions\\InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Colors/Cmyk/Color.php","lineNumber":66,"sourceCode":"    public static function create(int|Cyan $c, int|Magenta $m, int|Yellow $y, int|Key $k, float|Alpha $a = 1): self\n    {\n        return new self($c, $m, $y, $k, $a);\n    }\n\n    /**\n     * Parse CMYK color from string.\n     *\n     * @throws InvalidArgumentException\n     * @throws ColorException\n     */\n    public static function parse(string $input): self\n    {\n        try {\n            $color = InputHandler::usingDecoders([\n                StringColorDecoder::class,\n            ])->handle($input);\n        } catch (NotSupportedException | DriverException $e) {\n            throw new InvalidArgumentException(\n                'Unable to parse CMYK color from input \"' . $input . '\"',\n                previous: $e,\n            );\n        }\n\n        if (!$color instanceof self) {\n            throw new ColorException('Result must be instance of ' . self::class);\n        }\n\n        return $color;\n    }\n\n    /**\n     * {@inheritdoc}\n     *\n     * @see ColorInterface::colorspace()\n     */\n    public function colorspace(): ColorspaceInterface","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Colors/Cmyk/Color.php#L48-L84","documentation":"PixelateModifier's constructor requires a pixelation size of at least 1, because a zero or negative block size cannot produce a pixelation effect. The int type hint already rejects non-integers; this guard rejects the remaining invalid range.","triggerScenarios":"$image->pixelate(0); $image->pixelate(-10); computing size from a user 'intensity' parameter that can be zero or negative.","commonSituations":"Treating 0 as 'no pixelation' and forwarding it anyway; inverting a scale where higher = finer so pixel size ends up <= 0; default parameter set to 0 in a wrapper function.","solutions":["Skip the call for non-positive sizes: if ($size >= 1) { $image->pixelate($size); }.","Clamp user input: max(1, (int) $size).","In your wrapper, make 0 mean 'skip effect' explicitly instead of passing it through."],"exampleFix":"// before\n$image->pixelate($request->integer('size')); // 0 throws\n\n// after\n$size = max(1, $request->integer('size'));\n$image->pixelate($size);","handlingStrategy":"validation","validationCode":"$size = max(1, (int) $size);\n$image->pixelate($size);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat 0 as 'skip the effect', not as an argument.","Clamp user 'intensity' values to >= 1.","Cast to int: the parameter is typed and floats in strict mode are rejected."],"tags":["pixelate","argument-validation","modifier","php"],"backgroundTag":"argument-out-of-range","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}