mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Improved explanation of fromarray "mode" parameter
This commit is contained in:
parent
ae7c2cb2e6
commit
cea84e6b2d
|
@ -2773,7 +2773,7 @@ def fromarray(obj, mode=None):
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import numpy as np
|
import numpy as np
|
||||||
im = Image.open('hopper.jpg')
|
im = Image.open("hopper.jpg")
|
||||||
a = np.asarray(im)
|
a = np.asarray(im)
|
||||||
|
|
||||||
Then this can be used to convert it to a Pillow image::
|
Then this can be used to convert it to a Pillow image::
|
||||||
|
@ -2781,8 +2781,21 @@ def fromarray(obj, mode=None):
|
||||||
im = Image.fromarray(a)
|
im = Image.fromarray(a)
|
||||||
|
|
||||||
:param obj: Object with array interface
|
:param obj: Object with array interface
|
||||||
:param mode: Mode to use (will be determined from type if None)
|
:param mode: Optional mode to use when reading ``obj``. Will be determined from
|
||||||
See: :ref:`concept-modes`.
|
type if ``None``.
|
||||||
|
|
||||||
|
This will not be used to convert the data after reading, but will be used to
|
||||||
|
change how the data is read::
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
import numpy as np
|
||||||
|
a = np.full((1, 1), 300)
|
||||||
|
im = Image.fromarray(a, mode="L")
|
||||||
|
im.getpixel((0, 0)) # 44
|
||||||
|
im = Image.fromarray(a, mode="RGB")
|
||||||
|
im.getpixel((0, 0)) # (44, 1, 0)
|
||||||
|
|
||||||
|
See: :ref:`concept-modes` for general information about modes.
|
||||||
:returns: An image object.
|
:returns: An image object.
|
||||||
|
|
||||||
.. versionadded:: 1.1.6
|
.. versionadded:: 1.1.6
|
||||||
|
|
Loading…
Reference in New Issue
Block a user