Astral.Image.Format (Astral v0.1.8)

Copy Markdown View Source

Canonical image format normalization for Astral's image pipeline.

Summary

Functions

Return the canonical file extension for an output format.

Return supported local image file extensions.

Return the source format represented by a filesystem path.

Return a browser MIME type for a format.

Normalize a user-provided output format.

Return true when a format can be emitted by the optimization backend.

Normalize and validate a user-provided output format.

Return the suffix option expected by the Image package writer.

Types

t()

@type t() :: :jpg | :jpeg | :png | :webp | :avif | :svg | :unknown

Functions

extension(atom)

@spec extension(t()) :: String.t()

Return the canonical file extension for an output format.

extensions()

@spec extensions() :: [String.t()]

Return supported local image file extensions.

from_path(path)

@spec from_path(String.t()) :: t()

Return the source format represented by a filesystem path.

mime_type(format)

@spec mime_type(t()) :: String.t()

Return a browser MIME type for a format.

normalize(format)

@spec normalize(atom() | String.t()) :: t()

Normalize a user-provided output format.

optimizable?(format)

@spec optimizable?(term()) :: boolean()

Return true when a format can be emitted by the optimization backend.

output!(format)

@spec output!(atom() | String.t()) :: :jpg | :jpeg | :png | :webp | :avif

Normalize and validate a user-provided output format.

suffix(format)

@spec suffix(t()) :: String.t()

Return the suffix option expected by the Image package writer.