tf.image.decode_image

tf.image.decode_image(
    contents,
    channels=None,
    dtype=tf.uint8,
    name=None
)

Defined in tensorflow/python/ops/image_ops_impl.py.

Convenience function for decode_bmp, decode_gif, decode_jpeg, and decode_png.

Detects whether an image is a BMP, GIF, JPEG, or PNG, and performs the appropriate operation to convert the input bytes string into a Tensor of type dtype.

Args:

  • contents: 0-D string. The encoded image bytes.
  • channels: An optional int. Defaults to 0. Number of color channels for the decoded image.
  • dtype: The desired DType of the returned Tensor.
  • name: A name for the operation (optional)

Returns:

Tensor with type dtype and shape [height, width, num_channels] for BMP, JPEG, and PNG images and shape [num_frames, height, width, 3] for GIF images.

Raises:

  • ValueError: On incorrect number of channels.