From dc5d9c0f6ecb0972543cf92c64b1a3685dfc4886 Mon Sep 17 00:00:00 2001 From: Someone Date: Mon, 10 Jan 2022 19:36:38 +0100 Subject: [PATCH] modules/WSConvertWebp.py --- modules/WSConvertWebp.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/WSConvertWebp.py b/modules/WSConvertWebp.py index fefabe3..3db518e 100644 --- a/modules/WSConvertWebp.py +++ b/modules/WSConvertWebp.py @@ -23,10 +23,11 @@ class WSConvertWebp(AbstractWSHandler): for mmfile in post["metadata"]["files"]: if mmfile["mime_type"] == "image/webp": res = self.bot.api.get_file(mmfile["id"]) - open(tmpdirname+"/"+mmfile["id"]+".webp", 'wb').write(res.content) - image = Image.open(tmpdirname+"/"+mmfile["id"]+".webp").convert("RGB") - image.save(tmpdirname+"/"+mmfile["id"]+".png", "png") - tempfilenames.append(tmpdirname+"/"+mmfile["id"]+".png") + with open(tmpdirname+"/"+mmfile["id"]+".webp", 'wb') as tmpfile: + tmpfile.write(res.content) + image = Image.open(tmpdirname+"/"+mmfile["id"]+".webp").convert("RGB") + image.save(tmpdirname+"/"+mmfile["id"]+".png", "png") + tempfilenames.append(tmpdirname+"/"+mmfile["id"]+".png") if tempfilenames: root_id = post["id"] -- 2.43.0