# image/base64
Encode an image to bytes in its output format and return them as a standard
base64 string — convenient for data URIs and JSON payloads.
## Syntax
[image/base64 $img ?opts]
## Parameters
- `$img` — an `Image` value
- `$opts` — optional map; `:quality` and `:compression-level` as for
`image/bytes`
## Examples
set img [image/open "test/fixtures/images/test.png"] [image/base64 $img] # → "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAGCAYAAAD+…" [image/base64 [image/jpeg $img %{ quality 80 }]] # jpeg base64
## Returns
A standard-alphabet base64 string (with `=` padding), or `nil` when the
argument is not a live `Image` or encoding fails. Matches
`[crypto/b64-encode [image/bytes $img]]`.
## See Also
`image/bytes`, `image/encode`, `crypto/b64-encode`, `crypto/b64-decode`