detectImageMimeType function
sniffEncodedMediaFormat's MIME type for an IMAGE, else 'image/png' —
the fallback the LLM web arms have always used for bytes they could not
identify. Audio bytes get the fallback too: this answers "what kind of
image is this", and has never named an audio type.
Implementation
String detectImageMimeType(Uint8List bytes) {
final format = sniffEncodedMediaFormat(bytes);
return format != null && format.modality == EmbeddingModality.image
? format.mimeType
: EncodedMediaFormat.png.mimeType;
}