Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/dpostolachi/magickmime
- Owner: dpostolachi
- Created: 2020-10-13T18:49:29.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-06T22:12:43.000Z (8 months ago)
- Last Synced: 2024-04-06T23:22:49.425Z (8 months ago)
- Topics: elixir, mime-types
- Language: Elixir
- Homepage:
- Size: 142 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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).