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

Unable to decode from empty string

Error message

Unable to decode from empty string

What it means

Error "Unable to decode from empty string" thrown in Intervention/image.

Source

Thrown at src/InputHandler.php:105

    }

    /**
     * {@inheritdoc}
     *
     * @see InputHandlerInterface::handle()
     *
     * @throws InvalidArgumentException
     * @throws NotSupportedException
     * @throws DriverException
     */
    public function handle(mixed $input): ImageInterface|ColorInterface
    {
        if ($input === null) {
            throw new InvalidArgumentException('Unable to decode from null');
        }

        if ($input === '') {
            throw new InvalidArgumentException('Unable to decode from empty string');
        }

        // if handler has only one single decoder run it can run directly
        if (count($this->decoders) === 1) {
            return $this->decoders()->current()->decode($input);
        }

        // multiple decoders: try to find the matching decoder for the input
        foreach ($this->decoders() as $decoder) {
            if ($decoder->supports($input)) {
                return $decoder->decode($input);
            }
        }

        throw new NotSupportedException('Unprocessable input');
    }

    /**

View on GitHub (pinned to 5598b9e397)

Solutions

  1. Check the input string with empty() or strlen() before passing it to the decoder
  2. Verify the source (HTTP body, file read) actually returned data before decoding
  3. Return a 400-level response to clients that post empty image payloads

When it happens

Trigger: Thrown at src/InputHandler.php:105 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23). Data as JSON: /api/errors/bf286cca8065d85a. Report an issue: GitHub.