Intervention/image · error · InvalidArgumentException
Unsupported image source type "{type}"
Error message
Unsupported image source type "{type}" What it means
The driver tried every image input decoder and none could handle the input: each decoder's supports() returned false (surfacing as NotSupportedException from the handler), so the driver rethrows with the detected type of the input. The message tells you exactly what type was rejected.
Source
Thrown at src/Drivers/AbstractDriver.php:66
* @see DriverInterface::decodeImage()
*
* @throws InvalidArgumentException
* @throws ImageDecoderException
* @throws DriverException
*/
public function decodeImage(mixed $input, ?array $decoders = null): ImageInterface
{
$decoders = $decoders === null ? InputHandler::IMAGE_DECODERS : $decoders;
if (count($decoders) === 0) {
throw new InvalidArgumentException('No decoders in array');
}
try {
$result = InputHandler::usingDecoders($decoders, $this)->handle($input);
} catch (NotSupportedException) {
$type = is_object($input) ? $input::class : gettype($input);
throw new InvalidArgumentException('Unsupported image source type "' . $type . '"');
}
if (!$result instanceof ImageInterface) {
throw new ImageDecoderException('Result must be instance of ' . ImageInterface::class);
}
return $result;
}
/**
* {@inheritdoc}
*
* @see DriverInterface::decodeColor()
*
* @throws InvalidArgumentException
* @throws ColorDecoderException
* @throws DriverException
*/View on GitHub (pinned to 5598b9e397)
Solutions
- Convert the source to one of the always-supported forms - a binary string or a file path - before reading
- Null/empty-check the value before calling read() (the exception message's type will say 'null')
- For custom sources, implement DecoderInterface and pass it via decodeImage($input, $decoders)
Example fix
// before
$image = $manager->read($uploadedFile->getContent()); // may be false
// after
$data = $uploadedFile->getContent();
if ($data === false || $data === '') {
throw new \RuntimeException('Empty upload');
}
$image = $manager->read($data); Defensive patterns
Strategy: validation
Validate before calling
if ($input === null || is_array($input) || is_bool($input)) {
throw new \RuntimeException('Unsupported image source');
}
// normalize objects with binary content
if (is_object($input) && !$input instanceof \Stringable) {
$input = (string) method_exists($input, 'getContent') ? $input->getContent() : null;
} Type guard
function isReadableImageSource(mixed $value): bool
{
return is_string($value) || $value instanceof \Stringable || $value instanceof \Intervention\Image\Interfaces\ImageInterface;
} Try / catch
try {
$image = $manager->read($input);
} catch (\Intervention\Image\Exceptions\InvalidArgumentException $e) {
// message names the rejected type - normalize input and retry once
} Prevention
- Convert sources to a binary string or file path before read()
- Null-check failed fetches (file_get_contents returns false)
- Read the exception message - it states the exact input type
When it happens
Trigger: ImageManager::read() with null (e.g. failed file_get_contents), an array, a float/int, a resource of an unsupported type, or an object class for which no decoder is registered.
Common situations: Untyped upload fields that are null when empty; passing an SplFileInfo-like wrapper the chain does not know; passing a PSR-7 stream without the corresponding integration installed; variables that silently became false/null upstream.
Related errors
- Color object must be of type {ColorInterface::class}
- Base64-encoded data must be either of type string or instanc
- Image source must be of type SplFileInfo
- Unable to decode from null
- Unable to import color {colorClass} to {class}
AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23).
Data as JSON: /api/errors/de96a13c4440fac7.
Report an issue: GitHub.