Intervention/image · error · Intervention\Image\Exceptions\InvalidArgumentException

The stroke width must be in the range from 0 to 10

Error message

The stroke width must be in the range from 0 to 10

What it means

Error "The stroke width must be in the range from 0 to 10" thrown in Intervention/image.

Source

Thrown at src/Typography/Font.php:177

     *
     * @see FontInterface::strokeColor()
     */
    public function strokeColor(): null|string|ColorInterface
    {
        return $this->strokeColor;
    }

    /**
     * {@inheritdoc}
     *
     * @see FontInterface::setStrokeWidth()
     *
     * @throws InvalidArgumentException
     */
    public function setStrokeWidth(int $width): FontInterface
    {
        if (!in_array($width, range(0, 10))) {
            throw new InvalidArgumentException(
                'The stroke width must be in the range from 0 to 10',
            );
        }

        $this->strokeWidth = $width;

        return $this;
    }

    /**
     * {@inheritdoc}
     *
     * @see FontInterface::strokeWidth()
     */
    public function strokeWidth(): int
    {
        return $this->strokeWidth;
    }

View on GitHub (pinned to 5598b9e397)

Solutions

  1. Pass a stroke width between 0 and 10 to Font::strokeWidth()
  2. Clamp dynamic values with max(0, min(10, $width))
  3. Validate user input before configuring the font

When it happens

Trigger: Thrown at src/Typography/Font.php:177 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/7d9ea8e7dec913d7. Report an issue: GitHub.