Explorar el Código

Switch back to only allowing jpeg

Tulir Asokan hace 3 años
padre
commit
ab4d0ad78b
Se han modificado 1 ficheros con 4 adiciones y 4 borrados
  1. 4 4
      mautrix_instagram/portal.py

+ 4 - 4
mautrix_instagram/portal.py

@@ -287,12 +287,12 @@ class Portal(DBPortal, BasePortal):
         width: int | None = None,
         height: int | None = None,
     ) -> CommandResponse:
-        if mime_type not in ("image/jpeg", "image/webp"):
+        if mime_type != "image/jpeg":
             with BytesIO(data) as inp, BytesIO() as out:
                 img = Image.open(inp)
-                img.convert("RGBA").save(out, format="WEBP")
+                img.convert("RGB").save(out, format="JPEG", quality=80)
                 data = out.getvalue()
-                mime_type = "image/webp"
+                mime_type = "image/jpeg"
 
         self.log.trace(f"Uploading photo from {event_id} (mime: {mime_type})")
         upload_resp = await sender.client.upload_photo(
@@ -304,7 +304,7 @@ class Portal(DBPortal, BasePortal):
             ThreadItemType.CONFIGURE_PHOTO,
             client_context=request_id,
             upload_id=upload_resp.upload_id,
-            allow_full_aspect_ratio="1",
+            allow_full_aspect_ratio="true",
         )
 
     async def _handle_matrix_video(