Browse Source

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

Tulir Asokan 3 years ago
parent
commit
cb43fae3b2
1 changed files with 5 additions and 0 deletions
  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)