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

Invalid target size {$width}x{$height}

Error message

Invalid target size {$width}x{$height}

What it means

Error "Invalid target size {$width}x{$height}" thrown in Intervention/image.

Source

Thrown at src/Geometry/Rectangle.php:341

            $this->pivot()->x() - $rectangle->pivot()->x(),
            $this->pivot()->y() - $rectangle->pivot()->y(),
        );
    }

    /**
     * {@inheritdoc}
     *
     * @deprecated Use Intervention\Image\Size::class instead.
     * @see SizeInterface::resize()
     *
     * @throws InvalidArgumentException
     */
    public function resize(?int $width = null, ?int $height = null): SizeInterface
    {
        try {
            return $this->resizer($width, $height)->resize($this);
        } catch (InvalidArgumentException $e) {
            throw new InvalidArgumentException(
                'Invalid target size ' . $width . 'x' . $height,
                previous: $e,
            );
        }
    }

    /**
     * {@inheritdoc}
     *
     * @deprecated Use Intervention\Image\Size::class instead.
     * @see SizeInterface::resizeDown()
     *
     * @throws InvalidArgumentException
     */
    public function resizeDown(?int $width = null, ?int $height = null): SizeInterface
    {
        try {
            return $this->resizer($width, $height)->resizeDown($this);

View on GitHub (pinned to 5598b9e397)

Solutions

  1. Pass a target size with positive width and height; both must be >= 1
  2. Check upstream calculations producing $width/$height so they cannot yield 0 or negative values
  3. Validate user-supplied resize dimensions before calling size-related geometry methods

When it happens

Trigger: Thrown at src/Geometry/Rectangle.php:341 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/e8f318892e024859. Report an issue: GitHub.