jhn_magic (jhn_stdlib v5.10.1)
View SourceA media type determining library based on a subset of the types found in:
https://www.iana.org/assignments/media-types/media-types.xhtml
The trivially determined types are:
application/applefile application/gzip (rfc6713) application/msword application/pdf (rfc8118) application/rtf application/vnd.ms-excel application/vnd.ms-powerpoint application/vnd.visio application/zip image/bmp (rfc7903) image/jpeg (rfc2046) image/png (https://www.w3.org/TR/png/) text/calendar (rfc5545)
The following types requires deeper analysis possibly including uncompressing the file and are only determined when the {deep, true} option is provided, if not the encapsulating type, e.g., application/zip.
application/atom+xml (rfc4287) application/vnd.ms-visio.drawing.main+xml application/vnd.openxmlformats-officedocument.wordprocessingml.document application/ vnd.openxmlformats-officedocument.presentationml.presentation application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
So far only a few types are supported but more will be added.
Summary
Types
Functions
-spec media_type(binary()) -> media_type() | undefined.
Equivalent of calling media_type(File, [])
-spec media_type(binary(), opts()) -> media_type() | undefined.
The files media type is returned.
Options are: {deep, boolean()} -> does more expensive analysis default false