FormatParser (format_parser v1.4.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.

Link to this section Summary

Functions

Parses a file and extracts some information from it.

Link to this section Functions

@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

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"}