From e3aaa80c0690676286b408759449c9219fd54146 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sun, 12 Aug 2018 13:58:26 +1000 Subject: [PATCH] Added NumPy to documentation --- src/PIL/Image.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index c58952657..f13a98276 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -2440,9 +2440,20 @@ def fromarray(obj, mode=None): Creates an image memory from an object exporting the array interface (using the buffer protocol). - If obj is not contiguous, then the tobytes method is called + If **obj** is not contiguous, then the tobytes method is called and :py:func:`~PIL.Image.frombuffer` is used. + If you have an image in NumPy:: + + from PIL import Image + import numpy as np + im = Image.open('hopper.jpg') + a = numpy.asarray(im) + + Then this can be used to convert it to a Pillow image:: + + im = Image.fromarray(a) + :param obj: Object with array interface :param mode: Mode to use (will be determined from type if None) See: :ref:`concept-modes`.