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
- Check the input string with empty() or strlen() before passing it to the decoder
- Verify the source (HTTP body, file read) actually returned data before decoding
- 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
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23).
Data as JSON: /api/errors/bf286cca8065d85a.
Report an issue: GitHub.