瀏覽代碼

Add proper error message when pillow isn't installed. Fixes #41

Tulir Asokan 3 年之前
父節點
當前提交
cb43fae3b2
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      mautrix_instagram/portal.py

+ 5 - 0
mautrix_instagram/portal.py

@@ -296,6 +296,11 @@ class Portal(DBPortal, BasePortal):
         height: int | None = None,
     ) -> CommandResponse:
         if mime_type != "image/jpeg":
+            if Image is None:
+                raise NotImplementedError(
+                    "Instagram does not allow non-JPEG images, and Pillow is not installed, "
+                    "so the bridge couldn't convert the image automatically"
+                )
             with BytesIO(data) as inp, BytesIO() as out:
                 img = Image.open(inp)
                 img.convert("RGB").save(out, format="JPEG", quality=80)