Intervention/image · error · Intervention\Image\Exceptions\RuntimeException
Division by zero
Error message
Division by zero
What it means
Error "Division by zero" thrown in Intervention/image.
Source
Thrown at src/Geometry/Rectangle.php:180
public function setSize(int $width, int $height): self
{
return $this->setWidth($width)->setHeight($height);
}
/**
* {@inheritdoc}
*
* @deprecated Use Intervention\Image\Size::class instead.
* @see SizeInterface::aspectRatio()
*
* @throws RuntimeException
*/
public function aspectRatio(): float
{
try {
return $this->width() / $this->height();
} catch (DivisionByZeroError) {
throw new RuntimeException('Division by zero');
}
}
/**
* {@inheritdoc}
*
* @deprecated Use Intervention\Image\Size::class instead.
* @see SizeInterface::fitsWithin()
*/
public function fitsWithin(SizeInterface $size): bool
{
if ($this->width() > $size->width()) {
return false;
}
if ($this->height() > $size->height()) {
return false;
}View on GitHub (pinned to 5598b9e397)
Solutions
- Ensure the divisor (usually an aspect-ratio denominator derived from width or height) is not zero before the division
- Guard calls that compute ratios with a check for zero dimensions, e.g. if ($height === 0)
- Use the library's resize helpers which handle degenerate dimensions instead of computing ratios manually
When it happens
Trigger: Thrown at src/Geometry/Rectangle.php:180 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/415f89d9ad43eea0.
Report an issue: GitHub.