# `Image.BandFormat`
[🔗](https://github.com/elixir-image/image/blob/v0.65.0/lib/image/enum/band_format.ex#L1)

Functions to define and validate the band
formats of an image.

# `t`

```elixir
@type t() ::
  {:u, 8}
  | {:s, 8}
  | {:u, 16}
  | {:s, 16}
  | {:u, 32}
  | {:s, 32}
  | {:u, 64}
  | {:s, 64}
  | {:f, 32}
  | {:f, 64}
```

# `image_format_from_nx`

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

* Any `Nx` type like `{:u, 8}`.

### Returns

* `{:ok, band_format}` or

* `{:error, reason}`

# `known_band_formats`

Returns a list of the known band formats.

# `nx_format`

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

* Any `t:Vimage.t/0` of format in the list
  returned by `Image.BandFormat.known_band_formats/0`.

### Returns

* `{:ok, band_format}` or

* `{:error, reason}`

# `nx_format!`

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

* Any `t:Vimage.t/0` of format in the list
  returned by `Image.BandFormat.known_band_formats/0`.

### Returns

* `band_format` or

* raises an exception.

# `validate`

Validates a band format returning the band
format value required in the underlying
`Vix` code.

### Arguments

* `format` is any format returned by
  `Image.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}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
