Detects whether an image is a BMP, GIF, JPEG, JPEG XL, WebP or PNG, and
performs the appropriate operation to convert the input bytes string into a
Tensor of type dtype.
Args
contents
A Tensor of type string. 0-D. 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)
expand_animations
An optional bool. Defaults to True. Controls the
shape of the returned op's output. If True, the returned op will produce
a 4-D tensor for all GIFs and WebP images, animated or not, and a 3-D
tensor in all other cases. If, False, the returned op will produce a 3-D
tensor for all file types and will truncate animations to the first frame.
Returns
Tensor with type dtype and a 3- or 4-dimensional shape, depending on
the file type and the value of the expand_animations parameter.