Intervention/image · error · ImageDecoderException
SplFileInfo contains unsupported image type
Error message
SplFileInfo contains unsupported image type
What it means
The file behind the SplFileInfo could not be decoded. Subtlety worth knowing: because ImageDecoderException extends DecoderException, the catch (DecoderException) here also swallows the parent FilePathImageDecoder's more specific errors ('Failed to decode image data from file ...', 'Failed to retrieve image format') and relabels them - so this message can mean a genuinely unsupported format OR a plain corrupt file, with the detail lost.
Source
Thrown at src/Drivers/Imagick/Decoders/SplFileInfoImageDecoder.php:55
*
* @throws InvalidArgumentException
* @throws DirectoryNotFoundException
* @throws FileNotFoundException
* @throws FileNotReadableException
* @throws ImageDecoderException
* @throws DriverException
* @throws StateException
*/
public function decode(mixed $input): ImageInterface
{
if (!$input instanceof SplFileInfo) {
throw new InvalidArgumentException('Image source must be of type ' . SplFileInfo::class);
}
try {
return parent::decode(self::filePathFromSplFileInfoOrFail($input));
} catch (DecoderException) {
throw new ImageDecoderException(SplFileInfo::class . ' contains unsupported image type');
}
}
}
View on GitHub (pinned to 5598b9e397)
Solutions
- Check the real content of $file->getPathname() with finfo_file() or `file` before reading
- Confirm delegate availability: Imagick::queryFormats() should list the target format
- Install missing delegates or adjust policy.xml (see the file-based variant of this error)
- To recover the precise reason, read the path directly ($manager->read($splFileInfo->getPathname())) so FilePathImageDecoder's specific message surfaces unwrapped
Example fix
// before $image = $manager->read($uploadedFile); // Symfony UploadedFile; shows generic 'unsupported image type' // after: diagnose via the path to get the precise error $image = $manager->read($uploadedFile->getPathname()); // FilePathImageDecoder reports the exact failure
Defensive patterns
Strategy: validation
Validate before calling
$path = $splFileInfo->getPathname();
$mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path);
if (!str_starts_with((string) $mime, 'image/')) {
throw new RuntimeException('File is not an image: ' . $mime);
}
$image = $manager->read($splFileInfo); Try / catch
try {
$image = $manager->read($splFileInfo);
} catch (\Intervention\Image\Exceptions\ImageDecoderException $e) {
// generic label - re-read via ->getPathname() to get the precise underlying error
throw $e;
} Prevention
- Validate upload tmp files with finfo_file() before they reach the manager
- Remember this message also masks corrupt-file errors, not only unsupported formats
When it happens
Trigger: ImageManager::read(new SplFileInfo($path)) or reading a Symfony UploadedFile whose underlying file is corrupt, has a misleading extension, or is in a format the installed ImageMagick cannot decode (missing WebP/AVIF delegate, policy-blocked coder).
Common situations: Laravel/Symfony upload handling where the tmp file is a truncated transfer; extension spoofing (file.php renamed file.png); prod container missing delegates while local dev works.
Related errors
- contains unsupported image type
- Failed to decode image data from file "
- Base64-encoded data contains unsupported image type
- Failed to decode unsupported image format from binary data
- Failed to retrieve image format
AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23).
Data as JSON: /api/errors/3495c4d22f225557.
Report an issue: GitHub.