use direct io for mastodon images

workspace
Brendan Howell 7 years ago
parent 8fe7ba48ce
commit 97023f4e5a

@ -1,5 +1,6 @@
import codecs
import html
import io
import os.path
import random
import textwrap
@ -301,8 +302,8 @@ class PublicRelations(Bureau):
filename = img.url.rsplit('/',1)[1]
filename = "/tmp/" + filename
print("fetching", img.remote_url, filename)
urllib.request.urlretrieve(img.url, filename)
im = PIL.Image.open(filename)
req_data = requests.get(img.url)
im = PIL.Image.open(io.BytesIO(filename))
if im.mode in ("L", "RGB", "P"):
im = PIL.ImageOps.equalize(im)
im.thumbnail((576, 576), PIL.Image.ANTIALIAS)

Loading…
Cancel
Save