tf.io.decode_and_crop_jpeg

Decode and Crop a JPEG-encoded image to a uint8 tensor.

tf.io.decode_and_crop_jpeg(
    contents, crop_window, channels=0, ratio=1, fancy_upscaling=True,
    try_recover_truncated=False, acceptable_fraction=1, dct_method='', name=None
)

The attr channels indicates the desired number of color channels for the decoded image.

Accepted values are:

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.

It is equivalent to a combination of decode and crop, but much faster by only decoding partial jpeg image.

Args:

Returns:

A Tensor of type uint8.