Decode a JPEG-encoded image to a uint8 tensor.
tf.io.decode_jpeg(
contents: Annotated[Any, _atypes.String],
channels: int = 0,
ratio: int = 1,
fancy_upscaling: bool = True,
try_recover_truncated: bool = False,
acceptable_fraction: float = 1,
dct_method: str = '',
name=None
) -> Annotated[Any, _atypes.UInt8]
Used in the notebooks
Used in the guide | Used in the tutorials |
---|---|
The attr channels
indicates the desired number of color channels for the
decoded image.
Accepted values are:
- 0: Use the number of channels in the JPEG-encoded image.
- 1: output a grayscale image.
- 3: output an RGB image.
If needed, the JPEG-encoded image is transformed to match the requested number of color channels.
The attr ratio
allows downscaling the image by an integer factor during
decoding. Allowed values are: 1, 2, 4, and 8. This is much faster than
downscaling the image later.
This op also supports decoding PNGs and non-animated GIFs since the interface is
the same, though it is cleaner to use tf.io.decode_image
.
Returns | |
---|---|
A Tensor of type uint8 .
|