<br />

> [!NOTE]
> **Note:** This API is new and only available via `pip install tf-nightly`.

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/image_ops_impl.py#L3377-L3423) |

JPEG XL-encode an image.

#### View aliases


**Main aliases**

[`tf.image.encode_jxl`](https://www.tensorflow.org/api_docs/python/tf/io/encode_jxl.md.txt)
**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.image.encode_jxl`](https://www.tensorflow.org/api_docs/python/tf/io/encode_jxl.md.txt), [`tf.compat.v1.io.encode_jxl`](https://www.tensorflow.org/api_docs/python/tf/io/encode_jxl.md.txt)

<br />

```python
tf.io.encode_jxl(
    image, quality=95.0, effort=7, name=None
)
```

`image` is a rank-N Tensor of type uint8 or uint16 with shape `batch_dims +
[height, width, channels]`, where `channels` is:

- 1: for grayscale.
- 3: for RGB.
- 4: for RGBA.

`quality` is a JPEG-style quality factor in `[0.0, 100.0]`. It is mapped
internally to a JPEG XL Butteraugli distance using the same mapping as
`cjxl -q`: `100.0` encodes losslessly, `95.0` (the default) is high-quality
lossy encoding matching `encode_jpeg`, `90.0` is visually lossless, and
lower values compress more. Quality factors are not comparable across
codecs, so a given `quality` will not produce the same file size or visual
quality as the same value passed to [`tf.io.encode_jpeg`](https://www.tensorflow.org/api_docs/python/tf/io/encode_jpeg.md.txt).

The `effort` parameter (1 to 9) controls compression effort (default 7).

<br />

<br />

<br />

| ## Args ||
|---|---|
| `image` | A `Tensor`. Must be one of the following types: `uint8`, `uint16`. Rank N \>= 3 with shape `batch_dims + [height, width, channels]`. |
| `quality` | An optional `float`. Defaults to `95.0`. Quality factor in `[0.0, 100.0]`; `100.0` encodes losslessly, `95.0` is high-quality lossy, and lower values compress more. |
| `effort` | An optional `int`. Defaults to `7`. Effort setting from 1 (fastest) to 9 (slowest, best compression). |
| `name` | A name for the operation (optional). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `Tensor` of type `string`. ||

<br />