### Navigation

- index
- modules |
- next |
- previous |
- home|
- examples|
- tutorials|
- pyplot|
- docs »
- The Matplotlib API »
- matplotlib.pyplot »

# matplotlib.pyplot.imread

`matplotlib.pyplot.``imread`(*args, **kwargs)

  Read an image from a file into an array.

  fname may be a string path, a valid URL, or a Python file-like object. If using a file object, it must be opened in binary mode.

  If format is provided, will try to read file of that type, otherwise the format is deduced from the filename. If nothing can be deduced, PNG is tried.

  Return value is a `numpy.array`. For grayscale images, the return array is MxN. For RGB images, the return value is MxNx3. For RGBA images the return value is MxNx4.

  matplotlib can only read PNGs natively, but if PIL is installed, it will use it to load the image and return an array (if possible) which can be used with `imshow()`. Note, URL strings may not be compatible with PIL. Check the PIL documentation for more information.

## Examples using `matplotlib.pyplot.imread`

Clipping images with patches

Image Demo

Demo Annotation Box