# `Kino.Image`
[🔗](https://github.com/livebook-dev/kino/blob/v0.19.0/lib/kino/image.ex#L1)

A kino for rendering a binary image.

This is just a meta-struct that implements the `Kino.Render`
protocol, so that it gets rendered as the underlying image.

## Examples

    content = File.read!("/path/to/image.jpeg")
    Kino.Image.new(content, "image/jpeg")

# `common_image_type`

```elixir
@type common_image_type() :: :jpeg | :jpg | :png | :gif | :svg | :pixel
```

# `mime_type`

```elixir
@type mime_type() :: binary()
```

# `t`

```elixir
@opaque t()
```

# `new`

```elixir
@spec new(struct()) :: t()
```

Creates a new kino similarly to `new/2` from a compatible term.

Currently the supported terms are:

  * `Nx.Tensor` in HWC order

# `new`

```elixir
@spec new(binary(), common_image_type() | mime_type()) :: t()
```

Creates a new kino displaying the given binary image.

The given type can be either `:jpeg`/`:jpg`, `:png`, `:gif`, `:svg`, `:pixel`
or a string with image MIME type.

## Pixel data

Note that a special `image/x-pixel` MIME type is supported. The
binary consists of the following consecutive parts:

  * height - 32 bits (unsigned big-endian integer)
  * width - 32 bits (unsigned big-endian integer)
  * channels - 8 bits (unsigned integer)
  * data - pixel data in HWC order

Pixel data consists of 8-bit unsigned integers. The number of channels
can be either: 1 (grayscale), 2 (grayscale + alpha), 3 (RGB), or 4
(RGB + alpha).

---

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