Merge pull request #6215 from kolibril13/readURL

Add example to read image from URL
This commit is contained in:
Andrew Murray 2022-04-19 07:51:33 +10:00 committed by GitHub
commit 46ba6b51de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -504,6 +504,17 @@ image header. In addition, seek will also be used when the image data is read
tar file, you can use the :py:class:`~PIL.ContainerIO` or
:py:class:`~PIL.TarIO` modules to access it.
Reading from URL
^^^^^^^^^^^^^^^^
::
from PIL import Image
from urllib.request import urlopen
url = "https://python-pillow.org/images/pillow-logo.png"
img = Image.open(urlopen(url))
Reading from a tar archive
^^^^^^^^^^^^^^^^^^^^^^^^^^