Guess MIME type by file signatures.
If available in Hex, the package can be installed
by adding magickmime
to your list of dependencies in mix.exs
:
def deps do
[
{:magickmime, "~> 0.1.0"}
]
end
Works only with BitStrings, a length of 12 bytes should be enough to check all the supported mime types.
{ :ok, file } = File.open( "test/image.png", [ :read ] )
data = IO.binread( file, :all )
Magickmime.mime( data )
"image/png"
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/magickmime.