Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dpostolachi/magickmime

A library to guess MIME type from file signature.
https://github.com/dpostolachi/magickmime

elixir mime-types

Last synced: 8 days ago
JSON representation

A library to guess MIME type from file signature.

Awesome Lists containing this project

README

        

# Magickmime

Guess MIME type by file signatures.

## Installation

If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `magickmime` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[
{:magickmime, "~> 0.1.0"}
]
end
```

## Example

Works only with BitStrings, a length of 12 bytes should be enough to check all the supported mime types.

```elixir
{ :ok, file } = File.open( "test/image.png", [ :read ] )
data = IO.binread( file, :all )
Magickmime.mime( data )
"image/png"
```

Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/magickmime](https://hexdocs.pm/magickmime).