From e8e2a816fbbcec0d6a64496928fecff19c281d82 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 3 Jun 2025 18:33:57 +0300 Subject: =?UTF-8?q?fixes=20#5029=20(Telegram:=20=D0=BE=D1=82=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BA=D0=B0=20=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20gif)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Telegram/src/utils.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'protocols/Telegram/src/utils.cpp') diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index 94592127e0..2fbf18c2f2 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -183,8 +183,17 @@ TD::object_ptr makeFile(const wchar_t *pwszFilename) TG_FILE_REQUEST::Type AutoDetectType(const wchar_t *pwszFilename) { - if (ProtoGetAvatarFileFormat(pwszFilename) != PA_FORMAT_UNKNOWN) - return TG_FILE_REQUEST::PICTURE; + if (int iFormat = ProtoGetAvatarFileFormat(pwszFilename)) { + if (iFormat != PA_FORMAT_GIF) + return TG_FILE_REQUEST::PICTURE; + + if (auto *pBitmap = FreeImage_OpenMultiBitmapU(FIF_GIF, pwszFilename, FALSE, TRUE)) { + int iPages = FreeImage_GetPageCount(pBitmap); + FreeImage_CloseMultiBitmap(pBitmap); + if (iPages <= 1) + return TG_FILE_REQUEST::PICTURE; + } + } CMStringW path(pwszFilename); int idx = path.ReverseFind('.'); @@ -193,7 +202,7 @@ TG_FILE_REQUEST::Type AutoDetectType(const wchar_t *pwszFilename) auto wszExt = path.Right(path.GetLength() - idx - 1); wszExt.MakeLower(); - if (wszExt == L"mp4" || wszExt == L"webm") + if (wszExt == L"mp4" || wszExt == L"webm" || wszExt == L"gif") return TG_FILE_REQUEST::VIDEO; if (wszExt == L"mp3" || wszExt == "ogg" || wszExt == "oga" || wszExt == "wav") -- cgit v1.2.3