magic_number v0.0.2 MagicNumber

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

Summary

Types

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

Functions

Determine media type from its contents

Types

media_type :: {atom, atom}

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

application/zip
image/png

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