{"record":{"id":"28eff45266ca42a6","repo":"Intervention/image","slug":"position-must-be-either-integer-or-a-percent-value","errorCode":null,"errorMessage":"Position must be either integer or a percent value as string","messagePattern":"Position must be either integer or a percent value as string","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Modifiers/RemoveAnimationModifier.php","lineNumber":49,"sourceCode":"\n    /**\n     * Return the position of the selected frame as integer.\n     *\n     * @throws InvalidArgumentException\n     */\n    protected function normalizePosition(ImageInterface $image): int\n    {\n        if (is_int($this->position)) {\n            return $this->position;\n        }\n\n        if (is_numeric($this->position)) {\n            return (int) $this->position;\n        }\n\n        // calculate position from percentage value\n        if (preg_match(\"/^(?P<percent>[0-9]{1,3})%$/\", $this->position, $matches) !== 1) {\n            throw new InvalidArgumentException(\n                'Position must be either integer or a percent value as string',\n            );\n        }\n\n        $total = count($image);\n        $position = intval(round($total / 100 * intval($matches['percent'])));\n\n        return $position === $total ? $position - 1 : $position;\n    }\n}\n","sourceCodeStart":31,"sourceCodeEnd":60,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Modifiers/RemoveAnimationModifier.php#L31-L60","documentation":"Error \"Position must be either integer or a percent value as string\" thrown in Intervention/image.","triggerScenarios":"Thrown at src/Modifiers/RemoveAnimationModifier.php:49 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the position as an integer frame index (e.g. 0) or a percent string (e.g. \"25%\")","Cast float positions to int or convert them to a percent string","Reject other types (arrays, null) at the call site"],"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"}