LoginSignup
19
16

More than 5 years have passed since last update.

Python3でPillowを使ってURLから画像を読み込む

Posted at

StringIOでエラーが出てて辛かったけど,BytesIOがあるらしく,それを使うとできました.
Python3とPython2で文字列の扱いが異なる仕様がファイル読み込みまで影響が出てるんですね.

import io
import urllib.request
from PIL import Image
f = io.BytesIO(urllib.request.urlopen("画像のURL").read())
img = Image.open(f)
19
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
16