Philipp Hörist pushed to branch ogp-image-preview at gajim / gajim
Commits:
03a13257 by Philipp Hörist at 2026-02-22T22:58:35+01:00
Switch to JPEG
- - - - -
2 changed files:
- gajim/common/multiprocess/url_preview.py
- gajim/common/open_graph_parser.py
Changes:
=====================================
gajim/common/multiprocess/url_preview.py
=====================================
@@ -15,7 +15,7 @@
from gajim.common.open_graph_parser import OpenGraphParser
from gajim.common.open_graph_parser import OpenGraphThumbnail
-THUMBNAIL_SIZE = 128
+THUMBNAIL_SIZE = 256
def generate_url_preview(
@@ -61,5 +61,5 @@ def _make_thumbnail(content: bytes) -> OpenGraphThumbnail:
image = Image.open(io.BytesIO(content))
image.thumbnail((THUMBNAIL_SIZE, THUMBNAIL_SIZE))
thumbnail = io.BytesIO()
- image.save(thumbnail, format="PNG", optimize=True)
- return OpenGraphThumbnail.from_bytes(thumbnail.getvalue())
+ image.save(thumbnail, format="JPEG", optimize=True)
+ return OpenGraphThumbnail.from_bytes(thumbnail.getvalue(), "image/jpeg")
=====================================
gajim/common/open_graph_parser.py
=====================================
@@ -33,9 +33,7 @@ class OpenGraphThumbnail:
data: bytes
@classmethod
- def from_bytes(
- cls, data: bytes, media_type: str = "image/png"
- ) -> OpenGraphThumbnail:
+ def from_bytes(cls, data: bytes, media_type: str) -> OpenGraphThumbnail:
base64_data = base64.b64encode(data).decode()
uri = f"data:{media_type};base64,{base64_data}"
return cls(uri=uri, type=media_type, data=data)
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/03a1325755dee68cea13291aab9cf69f27af6f8d
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/03a1325755dee68cea13291aab9cf69f27af6f8d
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]