diff options
| author | George Hazan <george.hazan@gmail.com> | 2025-06-03 18:33:57 +0300 | 
|---|---|---|
| committer | George Hazan <george.hazan@gmail.com> | 2025-06-03 18:33:57 +0300 | 
| commit | e8e2a816fbbcec0d6a64496928fecff19c281d82 (patch) | |
| tree | 9d95ef13fb6235d84ea77b0fdc60f1569531d623 /protocols/Telegram | |
| parent | 69166430d42ec0ba524d256f190dadd662fd48e7 (diff) | |
fixes #5029 (Telegram: отправка анимированных gif)
Diffstat (limited to 'protocols/Telegram')
| -rw-r--r-- | protocols/Telegram/src/utils.cpp | 15 | 
1 files changed, 12 insertions, 3 deletions
| 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<TD::inputFileLocal> 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")
 | 
