Last active
April 18, 2018 01:15
-
-
Save shau-lok/e3e99abb61994a01df842190e5de2d01 to your computer and use it in GitHub Desktop.
python Pillow load image from bytes, Pillow 用法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import io | |
def load_image_from_bytes(image_data): | |
""" 从图片流中读取一张照片 """ | |
im = Image.open(io.BytesIO(image_data)) | |
print(im) | |
# >>> <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=300x240 at 0x102092B10> | |
def load_image_from_file_path(file_path): | |
""" 从路径中读取一张图片 """ | |
im = Image.open(file_path) | |
print(im) | |
# >>> <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=300x240 at 0x102092B10> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment