|View source on GitHub|
See Migration guide for more details.
tf.io.decode_image( contents, channels=None, dtype=tf.dtypes.uint8, name=None, expand_animations=True )
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
decode_gifreturns a 4-D array
[num_frames, height, width, 3], as opposed to
decode_png, which return 3-D arrays
[height, width, num_channels]. Make sure to take this into account when constructing your graph if you are intermixing GIF files with BMP, JPEG, and/or PNG files. Alternately, set the
expand_animationsargument of this function to
False, in which case the op will return 3-dimensional tensors and will truncate animated GIF files to the first frame.
Note: If the first frame of an animated GIF does not occupy the entire canvas (maximum frame width x maximum frame height), then it fills the unoccupied areas (in the first frame) with zeros (black). For frames after the first frame that does not occupy the entire canvas, it uses the previous frame to fill the unoccupied areas.
| || 0-D |
| || An optional |
| || The desired DType of the returned |
| ||A name for the operation (optional)|
| || Controls the shape of the returned op's output. If |
| ||On incorrect number of channels.|
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.