From ce37c6ef08b139d038fda41955802ae49d09887e Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 9 Jan 2023 04:19:59 +0400 Subject: [PATCH] Implement lossless jpeg progression --- Telegram/SourceFiles/storage/localimageloader.cpp | 12 +++++++++--- Telegram/lib_ui | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/storage/localimageloader.cpp b/Telegram/SourceFiles/storage/localimageloader.cpp index 9ef459abc8..c6c27c1b19 100644 --- a/Telegram/SourceFiles/storage/localimageloader.cpp +++ b/Telegram/SourceFiles/storage/localimageloader.cpp @@ -183,9 +183,15 @@ struct PreparedFileThumbnail { if (!bytes.isEmpty() && (bytes.size() <= full.width() * full.height() * kRecompressAfterBpp / 8) - && (format == u"jpeg"_q) - && Images::IsProgressiveJpeg(bytes)) { - return bytes; + && (format == u"jpeg"_q)) { + if (!Images::IsProgressiveJpeg(bytes)) { + if (const auto result = Images::MakeProgressiveJpeg(bytes) + ; !result.isEmpty()) { + return result; + } + } else { + return bytes; + } } auto result = QByteArray(); diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 3cb645f507..6cd13e1057 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 3cb645f50704b67537167e14623840a25fbdda7a +Subproject commit 6cd13e1057ee18f3c0e5168232e007dcaeee34b2