From b11c9d5675dfb0c4c1d2f5e985220671c35c7de0 Mon Sep 17 00:00:00 2001
From: miruka <miruka@disroot.org>
Date: Wed, 30 Oct 2019 05:47:22 -0400
Subject: [PATCH] Use lanczos filter and optimize saved thumbnail

---
 src/python/matrix_client.py                | 6 +++---
 src/qml/Chat/Timeline/EventMediaLoader.qml | 1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/python/matrix_client.py b/src/python/matrix_client.py
index ce006545..c44cd961 100644
--- a/src/python/matrix_client.py
+++ b/src/python/matrix_client.py
@@ -403,14 +403,14 @@ class MatrixClient(nio.AsyncClient):
                 raise UneededThumbnail()
 
             if not small:
-                thumb.thumbnail((512, 512))
+                thumb.thumbnail((512, 512), filter=PILImage.LANCZOS)
 
             with io.BytesIO() as out:
                 if thumb.mode == "RGBA":
-                    thumb.save(out, "PNG")
+                    thumb.save(out, "PNG", optimize=True)
                     mime = "image/png"
                 else:
-                    thumb.convert("RGB").save(out, "JPEG")
+                    thumb.convert("RGB").save(out, "JPEG", optimize=True)
                     mime = "image/jpeg"
 
                 content = out.getvalue()
diff --git a/src/qml/Chat/Timeline/EventMediaLoader.qml b/src/qml/Chat/Timeline/EventMediaLoader.qml
index e6056eaf..1f25f48d 100644
--- a/src/qml/Chat/Timeline/EventMediaLoader.qml
+++ b/src/qml/Chat/Timeline/EventMediaLoader.qml
@@ -52,6 +52,7 @@ HLoader {
 
 
     onPreviewUrlChanged: {
+        print( mediaUrl)
         if (type === EventDelegate.Media.Image) {
             var file  = "EventImage.qml"
             var props = { source: previewUrl, fullSource: mediaUrl }