<div dir="ltr">Reading the Magic-Header signatures first and then guessing from the file extension may be a better approach.<div><br></div><div>In spatialite gaia_exif.c, the function gaiaGuessBlobType has a collection of signatures to start with, combined with spatialite.c guess_mime_type returning the mime type as string.<br><div><br></div><div><div>  //----------------------------------------------------------</div><div>  // <a href="https://en.wikipedia.org/wiki/List_of_file_signatures">https://en.wikipedia.org/wiki/List_of_file_signatures</a></div><div>  // <a href="https://gist.github.com/navinpai/983632">https://gist.github.com/navinpai/983632</a></div><div>  // <a href="https://www.iana.org/assignments/media-types/media-types.xhtml">https://www.iana.org/assignments/media-types/media-types.xhtml</a></div><div>  //----------------------------------------------------------</div></div></div><div><br></div><div>Mark Johnson, Berlin Germany</div></div>