# `Expresso.Image`
[🔗](https://github.com/rellen/expresso/blob/main/lib/expresso/image.ex#L1)

The data URI of an image file

The document of a deck is one file, so an image cannot be a second file. This
module reads an image at render time and makes a data URI from the bytes.
The `img` element of `Expresso.Element.Image` then holds the image.

`media_type/1` gives the media type of a path, and `data_uri/1` gives the
full URI. The extension of the path gives the media type.

# `data_uri`

```elixir
@spec data_uri(Path.t()) :: {:ok, String.t()} | {:error, String.t()}
```

Make the data URI of an image path

A relative path starts from the working directory of the command.
`Expresso.PathTransformer` already joined the path of an image to the
`root` option of the deck. The function reads the file, and it gives an
error tuple for a file that it cannot read.

# `data_uri!`

```elixir
@spec data_uri!(Path.t()) :: String.t()
```

Make the data URI of an image path, or raise

`Expresso.Element.Image` calls this function, because a render function has
no way to report an error tuple.

# `extensions`

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

Return the extensions of the image types that Expresso knows

# `media_type`

```elixir
@spec media_type(Path.t()) :: {:ok, String.t()} | {:error, String.t()}
```

Give the media type of an image path

The function reads the extension of the path, and it does not read the file.
An extension that this module does not know gives an error tuple with the
list of the extensions.

---

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