{"record":{"id":"b22377a003627443","repo":"Intervention/image","slug":"transparency-must-be-in-range-0-to-1","errorCode":null,"errorMessage":"Transparency must be in range 0 to 1","messagePattern":"Transparency must be in range 0 to 1","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Modifiers/InsertModifier.php","lineNumber":28,"sourceCode":"use Intervention\\Image\\Interfaces\\ImageInterface;\nuse Intervention\\Image\\Interfaces\\PointInterface;\n\nclass InsertModifier extends SpecializableModifier\n{\n    /**\n     * Create new modifier object.\n     *\n     * @throws InvalidArgumentException\n     */\n    public function __construct(\n        public mixed $image,\n        public int $x = 0,\n        public int $y = 0,\n        public string|Alignment $alignment = Alignment::TOP_LEFT,\n        public float $transparency = 1,\n    ) {\n        if ($this->transparency < 0 || $this->transparency > 1) {\n            throw new InvalidArgumentException('Transparency must be in range 0 to 1');\n        }\n    }\n\n    /**\n     * Calculate position of the watermark to be inserted on the image.\n     */\n    public function position(ImageInterface $image, ImageInterface $watermark): PointInterface\n    {\n        $imageSize = $image->size()->movePivot(\n            $this->alignment,\n            $this->x,\n            $this->y,\n        );\n\n        $watermarkSize = $watermark->size()->movePivot(\n            $this->alignment,\n        );\n","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Modifiers/InsertModifier.php#L10-L46","documentation":"Error \"Transparency must be in range 0 to 1\" thrown in Intervention/image.","triggerScenarios":"Thrown at src/Modifiers/InsertModifier.php:28 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an opacity value between 0 and 1 to place()/insert(), e.g. 0.5 for 50%","Clamp dynamic values with max(0, min(1, $opacity))","Convert percentage values to the 0-1 range first (75% -> 0.75)"],"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"}