Intervention/image · error · Intervention\Image\Exceptions\InvalidArgumentException
Width of {$this::class} must be greater than or equal to 0
Error message
Width of {$this::class} must be greater than or equal to 0 What it means
Error "Width of {$this::class} must be greater than or equal to 0" thrown in Intervention/image.
Source
Thrown at src/Geometry/Rectangle.php:34
use Intervention\Image\Interfaces\DrawableInterface;
use Intervention\Image\Interfaces\PointInterface;
use Intervention\Image\Interfaces\SizeInterface;
use Traversable;
class Rectangle extends Polygon implements DrawableInterface, SizeInterface
{
/**
* Create new rectangle.
*
* @throws InvalidArgumentException
*/
public function __construct(
int $width,
int $height,
protected PointInterface $pivot = new Point(),
) {
if ($width < 0) {
throw new InvalidArgumentException(
'Width of ' . $this::class . ' must be greater than or equal to 0',
);
}
if ($height < 0) {
throw new InvalidArgumentException(
'Height of ' . $this::class . ' must be greater than or equal to 0',
);
}
parent::__construct([
new Point(0, 0),
new Point($width, 0),
new Point($width, $height * -1),
new Point(0, $height * -1),
], $pivot);
}
View on GitHub (pinned to 5598b9e397)
Solutions
- Pass a width of 0 or more when constructing the Rectangle
- Clamp negative computed widths with max(0, $width) before constructing the object
- Validate user input that feeds the width so negative values are rejected early
When it happens
Trigger: Thrown at src/Geometry/Rectangle.php:34 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/5f79bbead1411c1e.
Report an issue: GitHub.