{"record":{"id":"fcc60e18724365d9","repo":"Intervention/image","slug":"normalized-color-value-must-be-in-range-0-to-1","errorCode":null,"errorMessage":"Normalized color value must be in range 0 to 1","messagePattern":"Normalized color value must be in range 0 to 1","errorType":"exception","errorClass":"Intervention\\Image\\Exceptions\\InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Colors/Cmyk/Colorspace.php","lineNumber":57,"sourceCode":"     * @see ColorspaceInterface::colorFromNormalized()\n     *\n     * @throws InvalidArgumentException\n     */\n    public static function colorFromNormalized(array $normalized): CmykColor\n    {\n        if (!in_array(count($normalized), [4, 5])) {\n            throw new InvalidArgumentException('Number of color channels must be 4 or 5 for ' . static::class);\n        }\n\n        // add alpha value if missing\n        $normalized = count($normalized) === 4 ? array_pad($normalized, 5, 1) : $normalized;\n\n        return new Color(...array_map(\n            function (string $channel, null|float $normalized) {\n                try {\n                    return $channel::fromNormalized($normalized);\n                } catch (TypeError $e) {\n                    throw new InvalidArgumentException(\n                        'Normalized color value must be in range 0 to 1',\n                        previous: $e,\n                    );\n                }\n            },\n            self::$channels,\n            $normalized,\n        ));\n    }\n\n    /**\n     * {@inheritdoc}\n     *\n     * @see ColorspaceInterface::importColor()\n     *\n     * @throws ColorException\n     */\n    public function importColor(ColorInterface $color): CmykColor","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Colors/Cmyk/Colorspace.php#L39-L75","documentation":"RemoveAnimationModifier keeps one frame of an animated image and selects it by $position. Integer positions must be non-negative frame indexes; a negative int throws InvalidArgumentException in the constructor before anything is applied. (String positions follow a different, percent-based path.)","triggerScenarios":"$image->removeAnimation(-1) expecting Python-style negative indexing; passing a computed index like $frame - $offset that can dip below zero; forwarding a raw query-parameter integer.","commonSituations":"Assuming negative indexes count from the end (not supported); index arithmetic on user input; off-by-one loops around frame 0.","solutions":["Use 0-based non-negative indexes: ->removeAnimation(0) for the first frame.","Clamp computed indexes: max(0, $index).","For 'last frame' semantics, compute the frame count first ($image->count()) and pass count - 1."],"exampleFix":"// before\n$image->removeAnimation($frame - $offset); // can be -1, throws\n\n// after\n$position = max(0, $frame - $offset);\n$image->removeAnimation($position);","handlingStrategy":"validation","validationCode":"$position = max(0, (int) $position);\n$image->removeAnimation($position);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Negative indexes are not supported; compute last frame as count() - 1.","Clamp any index arithmetic result.","Validate the position parameter as min:0 when it comes from users."],"tags":["animation","frames","argument-validation","php"],"backgroundTag":"argument-out-of-range","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}