View Source Appwrite.Consts.ImageFormat (appwrite v0.1.9)
Provides constants and validation functions for image formats.
This module defines the image formats supported by the system, such as JPG, JPEG, GIF, PNG, and WebP. Helper functions are included to validate these formats, ensuring only recognized image formats are used.
Summary
Functions
Returns true if the given format
is a valid image format.
Guard clause to check if a given image format
is a valid image format code.
Validates the given format
and returns {:ok, format}
if it is valid,
or {:error, "Invalid image format"}
otherwise.
Returns the given format
if it is valid. Raises an ArgumentError
if the format
is invalid.
Functions
Returns true if the given format
is a valid image format.
Examples
iex> ImageFormat.is_valid_format?("jpg")
true
iex> ImageFormat.is_valid_format?("bmp")
false
Guard clause to check if a given image format
is a valid image format code.
Examples
iex> ImageFormat.valid_format("jpg")
true
iex> ImageFormat.valid_format("bmp")
false
Validates the given format
and returns {:ok, format}
if it is valid,
or {:error, "Invalid image format"}
otherwise.
Examples
iex> ImageFormat.validate_format("png")
{:ok, "png"}
iex> ImageFormat.validate_format("bmp")
{:error, "Invalid image format"}
Returns the given format
if it is valid. Raises an ArgumentError
if the format
is invalid.
Examples
iex> ImageFormat.validate_format!("jpg")
"jpg"
iex> ImageFormat.validate_format!("bmp")
** (ArgumentError) Invalid image format: "bmp"