Intervention/image · error · InvalidArgumentException

Transparency must be in range 0 to 1

Error message

Transparency must be in range 0 to 1

What it means

Error "Transparency must be in range 0 to 1" thrown in Intervention/image.

Source

Thrown at src/Modifiers/InsertModifier.php:28

use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\PointInterface;

class InsertModifier extends SpecializableModifier
{
    /**
     * Create new modifier object.
     *
     * @throws InvalidArgumentException
     */
    public function __construct(
        public mixed $image,
        public int $x = 0,
        public int $y = 0,
        public string|Alignment $alignment = Alignment::TOP_LEFT,
        public float $transparency = 1,
    ) {
        if ($this->transparency < 0 || $this->transparency > 1) {
            throw new InvalidArgumentException('Transparency must be in range 0 to 1');
        }
    }

    /**
     * Calculate position of the watermark to be inserted on the image.
     */
    public function position(ImageInterface $image, ImageInterface $watermark): PointInterface
    {
        $imageSize = $image->size()->movePivot(
            $this->alignment,
            $this->x,
            $this->y,
        );

        $watermarkSize = $watermark->size()->movePivot(
            $this->alignment,
        );

View on GitHub (pinned to 5598b9e397)

Solutions

  1. Pass an opacity value between 0 and 1 to place()/insert(), e.g. 0.5 for 50%
  2. Clamp dynamic values with max(0, min(1, $opacity))
  3. Convert percentage values to the 0-1 range first (75% -> 0.75)

When it happens

Trigger: Thrown at src/Modifiers/InsertModifier.php:28 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23). Data as JSON: /api/errors/b22377a003627443. Report an issue: GitHub.