# tf.keras.preprocessing.image.load_img

<br />

|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 2 version](https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/load_img) |

Loads an image into PIL format.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.keras.preprocessing.image.load_img`](https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/load_img), \`tf.compat.v2.keras.preprocessing.image.load_img\`

<br />

    tf.keras.preprocessing.image.load_img(
        path, grayscale=False, color_mode='rgb', target_size=None,
        interpolation='nearest'
    )

# Arguments

    path: Path to image file.
    grayscale: DEPRECATED use `color_mode="grayscale"`.
    color_mode: The desired image format. One of "grayscale", "rgb", "rgba".
        "grayscale" supports 8-bit images and 32-bit signed integer images.
        Default: "rgb".
    target_size: Either `None` (default to original size)
        or tuple of ints `(img_height, img_width)`.
    interpolation: Interpolation method used to resample the image if the
        target size is different from that of the loaded image.
        Supported methods are "nearest", "bilinear", and "bicubic".
        If PIL version 1.1.3 or newer is installed, "lanczos" is also
        supported. If PIL version 3.4.0 or newer is installed, "box" and
        "hamming" are also supported.
        Default: "nearest".

# Returns

    A PIL Image instance.

# Raises

    ImportError: if PIL is not available.
    ValueError: if interpolation method is not supported.