FormatParser.Image
(format_parser v2.14.0)
Copy Markdown
An Image struct and functions.
The Image struct contains the fields format, width_px, height_px, intrinsics and nature.
Supported Formats
| Format | Extension | Width/Height | Intrinsics |
|---|---|---|---|
:png | .png | ✓ | bit_depth, color_type, compression_method, filter_method, interlace_method, crc |
:jpg | .jpg, .jpeg | ✓ | - |
:gif | .gif | ✓ | - |
:bmp | .bmp | ✓ | - |
:tif | .tif, .tiff | ✓ | - |
:psd | .psd | ✓ | - |
:ico | .ico | ✓ | num_color_palette, color_planes, bits_per_pixel |
:cur | .cur | ✓ | num_color_palette, hotspot_horizontal_coords, hotspot_vertical_coords |
:cr2 | .cr2 | ✓ | date_time, model, preview_byte_count, preview_offset |
:nef | .nef | ✓ | date_time, model, preview_byte_count, preview_offset |
:webp | .webp | - | - |
:heic | .heic | - | - |
:avif | .avif | - | - |
:svg | .svg | - | - |
:jb2 | .jb2 | - | - |
:xcf | .xcf | - | - |
:exr | .exr | - | - |
Summary
Functions
Parses an image file or result.
Types
@type t() :: %FormatParser.Image{ format: atom() | nil, height_px: integer() | nil, intrinsics: map(), nature: atom(), width_px: integer() | nil }
A struct representing a parsed image file.
Fields
:format- The image format as an atom (e.g.,:png,:jpg,:gif):width_px- The image width in pixels, ornilif not available:height_px- The image height in pixels, ornilif not available:nature- Always:imagefor image files:intrinsics- A map containing format-specific metadata
Functions
Parses an image file or result.
- If given a tuple
{:error, file}wherefileis 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