magic_number v0.0.4 MagicNumber

The module to determine a file’s type from its magic number.

Summary

Types

A media type is a two-part identifier for file format. For example

Functions

Determine media type from its contents

Types

media_type :: {atom, atom}

A media type is a two-part identifier for file format. For example:

{:application, :zip} # application/zip
{:image, :png}       # image/png

See IANA list of official media types.

Functions

detect(arg1)

Specs

detect(binary) :: {:ok, media_type} | :error

Determine media type from its contents.

Examples

iex> MagicNumber.detect("GIF89a...")
{:ok, {:image, :gif}}
iex> MagicNumber.detect(<<>>)
:error