use direct io for mastodon images

workspace
Brendan Howell 6 years ago
parent 5ab819f2cb
commit 89bee5e6b2

@ -299,11 +299,11 @@ class PublicRelations(Bureau):
if media.type == "image": if media.type == "image":
img = media img = media
if img: if img:
filename = img.url.rsplit('/',1)[1] #filename = img.url.rsplit('/',1)[1]
filename = "/tmp/" + filename #filename = "/tmp/" + filename
print("fetching", img.remote_url, filename) #print("fetching", img.remote_url, filename)
req_data = requests.get(img.url) req_data = requests.get(img.url)
im = PIL.Image.open(io.StringIO(filename)) im = PIL.Image.open(io.StringIO(req_data.content))
if im.mode in ("L", "RGB", "P"): if im.mode in ("L", "RGB", "P"):
im = PIL.ImageOps.equalize(im) im = PIL.ImageOps.equalize(im)
im.thumbnail((576, 576), PIL.Image.ANTIALIAS) im.thumbnail((576, 576), PIL.Image.ANTIALIAS)

Loading…
Cancel
Save