FormatParser.Image (format_parser v2.6.0)

An Image struct and functions.

The Image struct contains the fields format, width_px, height_px, intrinsics and nature.

Summary

Functions

Parses an image file or result.

Types

t()

@type t() :: %FormatParser.Image{
  format: atom() | nil,
  height_px: integer() | nil,
  intrinsics: map(),
  nature: atom(),
  width_px: integer() | nil
}

Functions

parse(file)

@spec parse({:error, binary()} | binary() | any()) :: any()

Parses an image file or result.

  • If given a tuple {:error, file} where file is a binary, attempts to parse the image from the file.
  • If given a binary file, attempts to parse the image from the file.
  • For any other input, returns the input as-is.

Examples

iex> parse("image.png") # Parsed image result

iex> parse({:error, "image.png"}) # Parsed image result

iex> parse(:some_other_result) :some_other_result