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

Width must be greater than or equal to 1

Error message

Width must be greater than or equal to 1

What it means

Error "Width must be greater than or equal to 1" thrown in Intervention/image.

Source

Thrown at src/Geometry/Tools/Resizer.php:23

namespace Intervention\Image\Geometry\Tools;

use Intervention\Image\Alignment;
use Intervention\Image\Exceptions\InvalidArgumentException;
use Intervention\Image\Exceptions\StateException;
use Intervention\Image\Interfaces\SizeInterface;
use Intervention\Image\Size;

class Resizer
{
    /**
     * @throws InvalidArgumentException
     */
    public function __construct(
        protected ?int $width = null,
        protected ?int $height = null,
    ) {
        if (is_int($width) && $width < 1) {
            throw new InvalidArgumentException(
                'Width must be greater than or equal to 1',
            );
        }

        if (is_int($height) && $height < 1) {
            throw new InvalidArgumentException(
                'Height must be greater than or equal to 1',
            );
        }
    }

    /**
     * Static factory method to create resizer with given target size.
     *
     * @throws InvalidArgumentException
     */
    public static function to(?int $width = null, ?int $height = null): self
    {

View on GitHub (pinned to 5598b9e397)

Solutions

  1. Construct the Resizer with a width of at least 1
  2. If the width comes from a scaled computation, round up and clamp: max(1, (int) round($width))
  3. Reject zero/negative resize targets at the call site before building the Resizer

When it happens

Trigger: Thrown at src/Geometry/Tools/Resizer.php:23 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/00499b490a2df4ca. Report an issue: GitHub.