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
An optional tf.DType from: tf.uint8, tf.uint16, tf.float32. Defaults to tf.uint8.
The desired DType of the returned Tensor.
expand_animations
An optional bool. Defaults to True.
Controls the output shape of the returned op. If True, the returned op
will produce a 3-D tensor for PNG, JPEG, JPEG XL, and BMP files; and a
4-D tensor for all GIFs and WebP images, whether animated or not. If,
False, the returned op will produce a 3-D tensor for all file types
and will truncate animated images to the first frame.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-10-31 UTC."],[],[]]