{"record":{"id":"de96a13c4440fac7","repo":"Intervention/image","slug":"unsupported-image-source-type-type","errorCode":null,"errorMessage":"Unsupported image source type \"{type}\"","messagePattern":"Unsupported image source type \"(.+?)\"","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Drivers/AbstractDriver.php","lineNumber":66,"sourceCode":"     * @see DriverInterface::decodeImage()\n     *\n     * @throws InvalidArgumentException\n     * @throws ImageDecoderException\n     * @throws DriverException\n     */\n    public function decodeImage(mixed $input, ?array $decoders = null): ImageInterface\n    {\n        $decoders = $decoders === null ? InputHandler::IMAGE_DECODERS : $decoders;\n\n        if (count($decoders) === 0) {\n            throw new InvalidArgumentException('No decoders in array');\n        }\n\n        try {\n            $result = InputHandler::usingDecoders($decoders, $this)->handle($input);\n        } catch (NotSupportedException) {\n            $type = is_object($input) ? $input::class : gettype($input);\n            throw new InvalidArgumentException('Unsupported image source type \"' . $type . '\"');\n        }\n\n        if (!$result instanceof ImageInterface) {\n            throw new ImageDecoderException('Result must be instance of ' . ImageInterface::class);\n        }\n\n        return $result;\n    }\n\n    /**\n     * {@inheritdoc}\n     *\n     * @see DriverInterface::decodeColor()\n     *\n     * @throws InvalidArgumentException\n     * @throws ColorDecoderException\n     * @throws DriverException\n     */","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/AbstractDriver.php#L48-L84","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before\n$image = $manager->read($uploadedFile->getContent()); // may be false\n\n// after\n$data = $uploadedFile->getContent();\nif ($data === false || $data === '') {\n    throw new \\RuntimeException('Empty upload');\n}\n$image = $manager->read($data);","handlingStrategy":"validation","validationCode":"if ($input === null || is_array($input) || is_bool($input)) {\n    throw new \\RuntimeException('Unsupported image source');\n}\n// normalize objects with binary content\nif (is_object($input) && !$input instanceof \\Stringable) {\n    $input = (string) method_exists($input, 'getContent') ? $input->getContent() : null;\n}","typeGuard":"function isReadableImageSource(mixed $value): bool\n{\n    return is_string($value) || $value instanceof \\Stringable || $value instanceof \\Intervention\\Image\\Interfaces\\ImageInterface;\n}","tryCatchPattern":"try {\n    $image = $manager->read($input);\n} catch (\\Intervention\\Image\\Exceptions\\InvalidArgumentException $e) {\n    // message names the rejected type - normalize input and retry once\n}","preventionTips":["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"],"tags":["input","decoder","type-check","unsupported-type"],"backgroundTag":"unsupported-input-type","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}