FormatParser (format_parser v2.2.0)

The FormatParser Module

FormatParser parses a binary file and extracts the format and some additional information from it. It can deal with Audio, Video, Fonts, Images and Documents.

Summary

Functions

Parses a file and extracts some information from it.

Functions

parse(file)

@spec parse(binary()) :: struct()

Parses a file and extracts some information from it.

Takes a binary file as argument.

Returns a struct which contains all information that has been extracted from the file if the file is recognized.

Returns the following tuple if file not recognized: {:error, "Unknown"}.

Examples

iex> {:ok, file} = File.read("priv/test.jpg")
iex> FormatParser.parse(file)
%FormatParser.Image{format: :jpg, height_px: nil, nature: :image, width_px: nil}

iex> {:ok, file} = File.read("priv/test.html")
iex> FormatParser.parse(file)
{:error, "Unknown"}