Intervention/image · error · ImageDecoderException
SplFileInfo contains unsupported image type
Error message
SplFileInfo contains unsupported image type
What it means
The file behind the SplFileInfo exists and is readable, but no decoder in the GD driver chain could parse its contents, so the DecoderException is rethrown as 'unsupported image type'. The bytes are a format this GD build cannot read (WebP, AVIF, TIFF, BMP depending on compile flags) or corrupt data.
Source
Thrown at src/Drivers/Gd/Decoders/SplFileInfoImageDecoder.php:56
*
* @throws InvalidArgumentException
* @throws ImageDecoderException
* @throws DriverException
* @throws StateException
* @throws DirectoryNotFoundException
* @throws FileNotFoundException
* @throws FileNotReadableException
*/
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 gd_info() for the formats the build supports (WebP Support, AVIF Support, etc.)
- Use the Imagick driver when WebP/AVIF/TIFF input must be processed
- Convert the file upstream (imagemagick CLI, cloud converter) to PNG/JPEG
- Sniff the real MIME type with finfo instead of trusting the extension before handing the file to the manager
Example fix
// before
$image = $manager->read(new SplFileInfo('photo.webp')); // GD without webp
// after
if (pathinfo('photo.webp', PATHINFO_EXTENSION) === 'webp' && !(gd_info()['WebP Support'] ?? false)) {
$manager = ImageManager::usingDriver(ImagickDriver::class);
}
$image = $manager->read(new SplFileInfo('photo.webp')); Defensive patterns
Strategy: validation
Validate before calling
$formats = gd_info();
if (str_ends_with(strtolower($file), '.webp') && !($formats['WebP Support'] ?? false)) {
throw new RuntimeException('GD build lacks WebP support');
} Try / catch
try {
$image = $manager->read(new SplFileInfo($file));
} catch (ImageDecoderException $e) {
// retry with an Imagick-driver manager or reject the file
} Prevention
- Sniff MIME type of uploads instead of trusting extensions
- Document which formats your GD build supports and test for them at boot
- Keep an Imagick fallback path for exotic formats
When it happens
Trigger: $manager->read(new SplFileInfo('photo.webp')) on PHP whose GD lacks WebP support; a file whose extension does not match real content; an empty or zero-byte file that passed the readable check.
Common situations: Shared hosting or distro PHP where GD was compiled without webp/avif, processing user uploads by extension only, zero-byte files after a failed upload, files renamed to .jpg that are actually something else.
Related errors
- Unsupported media type (MIME) ${mediaType}.
- Unsupported media type (MIME) ${mime}.
- Base64-encoded data contains unsupported image type
- Failed to decode unsupported image format from binary data
- File contains unsupported image format
AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23).
Data as JSON: /api/errors/f11f8afc720c9578.
Report an issue: GitHub.