# tfg.io.exr.channels_to_ndarray

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/graphics/blob/master/tensorflow_graphics/io/exr.py#L37-L77) |

Copies channels from an OpenEXR.InputFile into a numpy array.

    tfg.io.exr.channels_to_ndarray(
        exr, channel_names
    )

If the EXR image is of size (width, height), the result will be a numpy array
of shape (height, width, len(channel_names)), where the last dimension holds
the channels in the order they were specified in channel_names. The requested
channels must all have the same datatype.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `exr` | An OpenEXR.InputFile that is already open. |
| `channel_names` | A list of strings naming the channels to read. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A numpy ndarray. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If the channels have different datatypes. |
| `RuntimeError` | If a channel has an unknown type. |

<br />