# DecodeImage

public final class **DecodeImage** 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.


*NOTE*: decode_gif returns a 4-D array \[num_frames, height, width, 3\], as
opposed to decode_bmp, decode_jpeg and 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_animations argument 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.

<br />

<br />

<br />

### Nested Classes

|---|---|---|---|
| class | [DecodeImage.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage.Options) || Optional attributes for `https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage` |

### Public Methods

|---|---|
| [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<T\> | [asOutput](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage#asOutput())() Returns the symbolic handle of a tensor. |
| static [DecodeImage.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage.Options) | [channels](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage#channels(java.lang.Long))(Long channels) |
| static \<T extends Number\> [DecodeImage](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage)\<T\> | [create](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage#create(org.tensorflow.op.Scope,%20org.tensorflow.Operand<java.lang.String>,%20java.lang.Class<T>,%20org.tensorflow.op.core.DecodeImage.Options...))([Scope](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<String\> contents, Class\<T\> dtype, [Options...](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage.Options) options) Factory method to create a class wrapping a new DecodeImage operation. |
| static [DecodeImage](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage)\<[UInt8](https://www.tensorflow.org/api_docs/java/org/tensorflow/types/UInt8)\> | [create](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage#create(org.tensorflow.op.Scope,%20org.tensorflow.Operand<java.lang.String>,%20org.tensorflow.op.core.DecodeImage.Options...))([Scope](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<String\> contents, [Options...](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage.Options) options) Factory method to create a class wrapping a new DecodeImage operation using default output types. |
| static [DecodeImage.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage.Options) | [expandAnimations](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage#expandAnimations(java.lang.Boolean))(Boolean expandAnimations) |
| [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<T\> | [image](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage#image())() 3-D with shape \`\[height, width, channels\]\` or 4-D with shape \`\[frame, height, width, channels\]\`.. |

### Inherited Methods

From class [org.tensorflow.op.PrimitiveOp](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp)

|---|---|
| final boolean | [equals](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp#equals(java.lang.Object))(Object obj) |
| final int | [hashCode](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp#hashCode())() |
| [Operation](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operation) | [op](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp#op())() Returns the underlying `https://www.tensorflow.org/api_docs/java/org/tensorflow/Operation` |
| final String | [toString](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp#toString())() |

From class java.lang.Object

|---|---|
| boolean | equals(Object arg0) |
| final Class\<?\> | getClass() |
| int | hashCode() |
| final void | notify() |
| final void | notifyAll() |
| String | toString() |
| final void | wait(long arg0, int arg1) |
| final void | wait(long arg0) |
| final void | wait() |

From interface [org.tensorflow.Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)

|---|---|
| abstract [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<T\> | [asOutput](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand#asOutput())() Returns the symbolic handle of a tensor. |

## Public Methods

#### public [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<T\>
**asOutput**
()

Returns the symbolic handle of a tensor.

Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is
used to obtain a symbolic handle that represents the computation of the input.

<br />

#### public static [DecodeImage.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage.Options)
**channels**
(Long channels)

<br />

##### Parameters

| channels | Number of color channels for the decoded image. |
|---|---|

#### public static [DecodeImage](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage)\<T\>
**create**
([Scope](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<String\> contents, Class\<T\> dtype, [Options...](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage.Options) options)

Factory method to create a class wrapping a new DecodeImage operation.

##### Parameters

| scope | current scope |
| contents | 0-D. The encoded image bytes. |
| dtype | The desired DType of the returned Tensor. |
| options | carries optional attributes values |
|---|---|

##### Returns

- a new instance of DecodeImage

#### public static [DecodeImage](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage)\<[UInt8](https://www.tensorflow.org/api_docs/java/org/tensorflow/types/UInt8)\>
**create**
([Scope](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<String\> contents, [Options...](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage.Options) options)

Factory method to create a class wrapping a new DecodeImage operation using default output types.

##### Parameters

| scope | current scope |
| contents | 0-D. The encoded image bytes. |
| options | carries optional attributes values |
|---|---|

##### Returns

- a new instance of DecodeImage

#### public static [DecodeImage.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/DecodeImage.Options)
**expandAnimations**
(Boolean expandAnimations)

<br />

##### Parameters

| expandAnimations | Controls the output shape of the returned op. If True, the returned op will produce a 3-D tensor for PNG, JPEG, and BMP files; and a 4-D tensor for all GIFs, whether animated or not. If, False, the returned op will produce a 3-D tensor for all file types and will truncate animated GIFs to the first frame. |
|---|---|

#### public [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<T\>
**image**
()

3-D with shape \`\[height, width, channels\]\` or 4-D with shape
\`\[frame, height, width, channels\]\`..