image is a rank-N uint8 or uint16 Tensor of shape batch_dims + [height, width, channels]
where channels is:
1: for grayscale.
3: for RGB.
4: for RGBA.
quality is mapped internally to a Butteraugli distance, using the same
mapping as cjxl -q: 100.0 maps to distance 0.0 (lossless modular encoding),
95.0 maps to distance 0.5 (default lossy VarDCT encoding), 90.0 maps to
distance 1.0, and 0.0 maps to distance 25.0. Note that quality factors are not
comparable across codecs; a given quality will not produce the same file size
or visual quality as the same value passed to tf.io.encode_jpeg.
Args
image
A Tensor. Must be one of the following types: uint8, uint16.
Images to encode. Rank N >= 3 with shape batch_dims + [height, width, channels].
quality
An optional float. Defaults to 95.
JPEG-style quality factor in [0.0, 100.0]. Defaults to 95.0 to match
encode_jpeg. 100.0 encodes losslessly, 90.0 is visually lossless, and lower
values compress more.
effort
An optional int. Defaults to 7.
Effort level from 1 (fastest) to 9 (slowest/best compression).
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-10-31 UTC."],[],[]]