Functions to define and validate the band formats of an image.
Summary
Functions
Returns a list of the known band formats.
Validates a band format returning the band
format value required in the underlying
Vix code.
Types
Functions
Returns the Image format type for an
Nx format type.
Image uses the same type formats as Nx so
this function is more a validation than a
conversion.
Arguments
nx_typeis anyNxtype, such as{:u, 8}.
Returns
{:ok, band_format}or{:error, reason}.
Examples
iex> Image.BandFormat.image_format_from_nx({:u, 8})
{:ok, :VIPS_FORMAT_UCHAR}
iex> Image.BandFormat.image_format_from_nx({:u, 16})
{:ok, :VIPS_FORMAT_USHORT}
Returns a list of the known band formats.
Returns the Nx format type for an
Image or image format type.
Image uses the same type formats as Nx so
this function is more a validation than a
conversion.
Arguments
image_or_formatis anyVix.Vips.Image.t/0, or any format in the list returned byImage.BandFormat.known_band_formats/0.
Returns
{:ok, band_format}or{:error, reason}.
Examples
iex> Image.BandFormat.nx_format(:VIPS_FORMAT_UCHAR)
{:ok, {:u, 8}}
iex> image = Image.new!(2, 2, color: :red)
iex> Image.BandFormat.nx_format(image)
{:ok, {:u, 8}}
Returns the Nx format type for an
Image or image format type or raises
an exception.
Image uses the same type formats as Nx so
this function is more a validation than a
conversion.
Arguments
image_or_formatis anyVix.Vips.Image.t/0, or any format in the list returned byImage.BandFormat.known_band_formats/0.
Returns
band_formatorraises an exception.
Examples
iex> Image.BandFormat.nx_format!(:VIPS_FORMAT_USHORT)
{:u, 16}
iex> image = Image.new!(2, 2, color: :red)
iex> Image.BandFormat.nx_format!(image)
{:u, 8}
Validates a band format returning the band
format value required in the underlying
Vix code.
Arguments
formatis any format returned byImage.BandFormat.known_band_formats/0.
Returns
{:ok, validated_foramt}or{:error, reason}
Examples
iex> Image.BandFormat.validate({:u, 8})
{:ok, :VIPS_FORMAT_UCHAR}
iex> Image.BandFormat.validate(:u8)
{:ok, :VIPS_FORMAT_UCHAR}
iex> Image.BandFormat.validate(:VIPS_FORMAT_UCHAR)
{:ok, :VIPS_FORMAT_UCHAR}