mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 18:26:17 +03:00
Use BytesIO instead of StringIO [ci skip]
This commit is contained in:
parent
455a113a22
commit
1f58028173
|
@ -464,17 +464,17 @@ Reading from an open file
|
|||
with open("hopper.ppm", "rb") as fp:
|
||||
im = Image.open(fp)
|
||||
|
||||
To read an image from string data, use the :py:class:`~StringIO.StringIO`
|
||||
To read an image from binary data, use the :py:class:`~io.BytesIO`
|
||||
class:
|
||||
|
||||
Reading from a string
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
Reading from binary data
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
from PIL import Image
|
||||
import StringIO
|
||||
im = Image.open(StringIO.StringIO(buffer))
|
||||
import io
|
||||
im = Image.open(io.BytesIO(buffer))
|
||||
|
||||
Note that the library rewinds the file (using ``seek(0)``) before reading the
|
||||
image header. In addition, seek will also be used when the image data is read
|
||||
|
|
Loading…
Reference in New Issue
Block a user