telegramdesktop / tdesktop

Telegram Desktop messaging app
https://desktop.telegram.org/
Other
26.12k stars 5.18k forks source link

Increase the photo size limit of 1280 pixels #6520

Closed mrogin-technic closed 4 months ago

mrogin-technic commented 5 years ago

telegramdesktop uses an image size limit of 1280x1280 pixels although the Telegram API allows a photo sizes up to 2560 pixels. Photos sent with telegramdesktop therefore don't look good on current tablets and smartphones. Therefore, it should be possible to increase the limit from 1280 to 1920 or 2560 px using manual settings. A setting for the strength of the JPEG compression would also be very useful. Currently the fixed downscaling limit and JPEG compression is hardcoded in: /SourceFiles/storage/localimageloader.cpp

jeffythedragonslayer commented 4 years ago

These should be declared constexpr at the top of the file. I will try to open a pull request once I get my build working.

mrg21 commented 4 years ago

If it should be configurable for each sending, then it would have to be integrated into this window. https://i.vgy.me/GkxWSJ.png With an additional line to selection the maximum size (1280/1920/2560) and JPG compression (LQ/MQ/HQ). Otherwise simply change the default globally in the settings for all image files instead of the fixed values 1280 and 87 for JPG compression in the current source code:

else if (_type != SendMediaType::File) {
...
auto full = (w > 1280 || h > 1280) ? fullimage.scaled(1280, 1280, Qt::KeepAspectRatio,...
...
full.save(&buffer, "JPG", 87);

https://core.telegram.org/constructor/photoSize

mrogin-technic commented 4 years ago

This enhancement should also fix the following bug https://github.com/telegramdesktop/tdesktop/issues/2206

mrogin-technic commented 4 years ago

After more than one year, this issue is still open. Are there no plans to solve the problem of the poor image quality when viewing and sending photos in Telegram Desktop?

SmartManoj commented 4 years ago

Does the "easy pick" mean the "good first issue"?

ilya-fedin commented 3 years ago

Does the "easy pick" mean the "good first issue"?

No, theoretically it means that this is easy to fix for third-party contributors.

But as far as I know, this issue is definitely not an "easy pick", since core developers want to fix this only in a way that wouldn't increase traffic consumption without opening the image in fullscreen. In other words, fixing this issue requires a rewrite of how tdesktop downloads photos, to separate in-chat downloading and media view downloading, what also means that new UI elements are needed to show the download progress in media view.

stale[bot] commented 3 years ago

Hey there!

This issue was inactive for a long time and will be automatically closed in 30 days if there isn't any further activity. We therefore assume that the user has lost interest or resolved the problem on their own.

Don't worry though; if this is an error, let us know with a comment and we'll be happy to reopen the issue.

Thanks!

Remu-rin commented 3 years ago

Still relevant.

mrg21 commented 3 years ago

Signal now allows to sharing images in 4K (4096 pixels). It's really time that Telegram allows more than 1280 pixels.

Neurotoxin001 commented 1 year ago

How they upload 2560 image size? https://t.me/tass_agency/170735

When I reupload this image I got only 1280.

4.4.1

Aokromes commented 1 year ago

https://github.com/telegramdesktop/tdesktop/issues/2206

Neurotoxin001 commented 1 year ago

You need to reopen this issue because this https://github.com/telegramdesktop/tdesktop/issues/2206 is not what here been requested. And this fix https://github.com/telegramdesktop/tdesktop/commit/0f3ec7893d5f4f6ad4a2e3401551c95ce335740a is not belong to this issue.

Neurotoxin001 commented 1 year ago

@Aokromes reopen please

Neurotoxin001 commented 1 year ago

@john-preston Maybe you could please enable the ability to upload 2560px images at least in the experimental settings?

john-preston commented 1 year ago

@Neurotoxin001 Ok, I'll add a setting for now.

Neurotoxin001 commented 1 year ago

I found little visual bug. Every time when I enter in chat/channel that have 2560px image every time it's loading. You can see 0.1 sec blur before it's loaded:

https://user-images.githubusercontent.com/39812401/210274617-5ff51d9f-4226-449f-a702-fdf3e050681b.mp4

john-preston commented 1 year ago

It is that way with all photos, it's just large ones load a little longer than the small ones. They're loading async and unload when you close the chat, it is intended.

mrg21 commented 1 year ago

It works well for me ;) thank you very much. Too bad it took more than 3 years after the opening of this issue.

The JPEG compression is still hardcoded with "writer.setQuality(87);" Would be very nice if we could also change the JPEG compression (as suggested in post1 of this issue) in the experimental settings.

ilya-fedin commented 1 year ago

This won't help as the server re-compresses anyway

AlttiRi commented 11 months ago

What's about to move the option "Send large photos" from "Advanced > Experimental settings" to just "Advanced"?

In "Data and storage" section.


I use it since it was appeared. It works without problems.

"Experimental settings" are practically hidden settings, as well as, it have a "scary" description that intents people to close it immediately.

I think that the notable count of people who opened "Advanced" setting would enable "Send large photos" if it was in "Data and storage" section.

Ideally, it would nice, if the option was enabled by default, but even moving it from "Experimental settings" to "Advanced" would be fine too.

ilya-fedin commented 11 months ago

It works without problems.

Are you sure? As far as I'm aware, the Android client renders such photos incorrectly.

mrogin-technic commented 11 months ago

It works without problems.

Are you sure? As far as I'm aware, the Android client renders such photos incorrectly.

I have been using the option since the beginning and so far it has always worked correctly on all Android devices.

Neurotoxin001 commented 11 months ago

As far as I'm aware, the Android client renders such photos incorrectly.

I've never seen any complaints from subscribers about it.

AlttiRi commented 11 months ago

Android application just uses 1280 px resample for them. Sadly, for downloading too. BTW, this 1280 px resample of a photo, uploaded with "Send large photos" option enabled, looks better on Android (it has notably more details, with a little bigger file size). No problem with rendering, just a bit different JPEG compression ratio.

For example: Telegram-1280px-resamples.zip

QuAzI commented 4 months ago

As far as I'm aware, the Android client renders such photos incorrectly.

Currently, the Windows client also makes photos extremely worse. It's not so critical while it some memes or screenshots, but when you are a photographer - it's a reason to send all photos without compression. But while you use photos without compression preview/gallery/navigation/selection so terrible. I tried to resize some photos by hand for same size to prevent resampling, but telegram resample they too. As a result, quality was decreased, but image size was increased!

ilya-fedin commented 4 months ago

Currently, the Windows client also makes photos extremely worse.

You mean worse than Android? If you have any constructive suggestions on how the parity could be reached, please do.

QuAzI commented 4 months ago

I would rather not choose which client has worse quality, as it senseless. 1280px isn't good choice for photos in 2024 in any way. It's terrible even for phones since 2020, but on PC I am pretty sure almost no one uses 1280px desktop resolution for many years. As I can see, iOS users have 2560px limits by default even without a premium account. Why other people have this strange limitation? Moreover, good option to not resample images which already prepared while it does not get any pros.

Neurotoxin001 commented 4 months ago

iOS app have 1280px https://github.com/TelegramMessenger/Telegram-iOS/issues/943

And the developer doesn't even want to introduce an experimental setting to enable 2560px like on tdesktop

QuAzI commented 4 months ago

I am pretty sure that people with 4k displays crying with blood

ilya-fedin commented 4 months ago

I would rather not choose which client has worse quality, as it senseless.

Ah, ok. I've read your message like tdesktop is worse than Android.

AlttiRi commented 4 months ago

Currently, the Windows client also makes photos extremely worse.

"Send large photos" option only increases the allowed dimension from "1280x1280 px" to "2560x2560 px" (it's 4 times bigger). But it still requires the image to be well compressed. Otherwise, TG will do extra compression.

For example, this well compressed image is 2048x1534 px with 409 KB size: https://pbs.twimg.com/media/GOCvscJaMAEQ9-R?format=jpg&name=large After uploading it to TG as a photo, I can download it and it will be the same file with no change. GOCvscJaMAEQ9-R and photo_2024-05-23_20-30-40.jpg are byte identical.

For this 1080x1440, 316 KB image: https://i.imgur.com/zW6uPhx.jpeg TG does "remuxing". I download a different file with 309 KB size, but both images are pixel identical.


However, when I do an export, I get the re-encoded images. The quality for both these images are really close to the original, but the exported images are not pixel identical to the original ones.


As I can see, iOS users have 2560px limits by default

Only Telegram Desktop users can send larger images (up to 2560x2560 px) if they turned on the "Send large photos" option. Other clients can send only photos reduced down to 1280x1280 px. Every Telegram Desktop user can view/download the larger images even while they have no enabled the "Send large photos" option. Others client's users will get the 1280 px resample version of it.

Remu-rin commented 4 months ago

Every Telegram Desktop user can view/download the larger images even while they have no enabled the "Send large photos" option.

Btw, Android client still cannot do that and it shows and downloads 1280 version of image, even if it was uploaded via Tdesktop with experimental setting or via bot/API. Please upvote allow sending QHD pictures

QuAzI commented 4 months ago

But it still requires the image to be well compressed. Otherwise, TG will do extra compression.

Occasionally, it results in a file which size higher than the source with worse quality at the same time.

I found that TG constantly trying to apply the next preset

JPEG, progressive, quality: 84

And if you enable Large Photos

JPEG, progressive, quality: 87

So sense not only in x4 pixels, quality should be better. But... it's still so terrible.

After uploading it to TG as a photo, I can download it and it will be the same file with no change.

Use a different host as receiver. As TG has local cache and file which you can save back differ than file which user get.

Others client's users will get the 1280 px resample version of it.

Yeah, I've checked. That's terrible and breaks all my tries to have a normal gallery.

Currently, even the slider not switches between different groups of photos. You have to close one to start slide other. image

And previews/grouping/selection terrible when you upload photos as files.

mrogin-technic commented 4 months ago

I don't see a problem on my desktop. When I use this 4k photo, then tdesktop resized it to the following photo:

Test-Res-4k_tg-desktop-default

And with activated "Send large photos" on to: Test-Res-4k_tg-desktop-large

Yes, it would be very nice if we could also set the quality level manually in the tdesktop settings (see post1), but the current fixed quality level is acceptable for me.

ilya-fedin commented 4 months ago

quality level manually in the tdesktop settings

This wouldn't really help as the recompression is done by the server

ilya-fedin commented 4 months ago

One can can ensure tdesktop doesn't get in the way by following this restriction: https://github.com/telegramdesktop/tdesktop/blob/364f62660c7a1a136a48275d7b63610d9d4ba8cb/Telegram/SourceFiles/storage/localimageloader.cpp#L185-L186

QuAzI commented 4 months ago

but the current fixed quality level is acceptable for me.

Maybe because you don't need this feature at all as you are not a photographer and have 17" display, I don't know. Because it's easy to see the difference between those two simple images. Current images quality is fine for some screenshots (if you have only one small monitor) and memes, but not for photos.

mrogin-technic commented 4 months ago

but the current fixed quality level is acceptable for me.

Maybe because you don't need this feature at all as you are not a photographer ...

I am the author of this issue (almost 5 years ago) and the 1280 limitation with the poor quality was definitely not acceptable, even for normal smartphones from 2019 and certainly not for tablets or PC monitors. However, "Send large photos" and increase the limit from 1280 to 2560 was a huge step and has significantly increased the quality, which is now enough for most people to show photos. But yes, the compression with the current fixed values is visible and that's why I still wish that we could set it manually for ourselves in the settings.

Current images quality is fine for some screenshots (if you have only one small monitor) and memes, but not for photos.

My experience is the other way around: for screenshots the current compression is too bad, but acceptable for photos.

ilya-fedin commented 4 months ago

If the issue is only with screenshots, it might be not compression but the scaling algorithm Qt's QImage uses. As people report screen sharing has readability problems just as well.

john-preston commented 4 months ago

Currently, even the slider not switches between different groups of photos.

But you show group of files (images, sent as files, not as photos), followed by a photo. They won't switch to one another, they reside in different galleries.

QuAzI commented 4 months ago

@john-preston but other galleries switch if content type not mixed between photo/file. Manual downloading of photos just to overview them also not friendly. And, of course, it's terrible from the point of storage and traffic when you have to upload 20Mb as file because Telegram downscale it to ~250kb by default with a corresponding loss of quality. Option for "Quality" like for videos would be nice

john-preston commented 4 months ago

Well, right now you use "uncompressed" sending, that is not for photos at all, or at least not for viewing in-app or looking for traffic - this function is made specifically for sending files, exact bytes you have on your drive.

Sending compressed photos is done as it can be with current Telegram server implementation. By default by compressing to 1280x1280, but with option to compress to 2560x2560, but in case the resulting jpeg doesn't meet some criteria checked on the server, the server will recompress it. There is nothing I can do with that flow, if I understand correctly.

QuAzI commented 4 months ago

that is not for photos at all

Yeah. That what I mean - sending as files isn't for photos in general. Quality should be improved in different way. Send as File not helps and even can ruin security (GPS stored in EXIF, for example). These photo files also excluded from "View all photos" and from Menu - Channel - Photos

Moreover, currently, users upload photos at least twice (in the default way, then "as file" when found that the default way quality isn't good) and each try stored in Telegram CDN.

There is nothing I can do with that flow

Would it be possible to at least add the Large Photos option for all clients, not only PC? Currently, I have to send photos from my phone to PC as files to upload 2560px (via Telegram of-course). Would it be possible to improve the compression ratio, as 84% is terrible? And the last one propose - enable 2560px downloading if source has it instead of always using 1280px while no Large Photos enabled?

Aokromes commented 4 months ago

Would it be possible to at least add the Large Photos option for all clients, not only PC? Currently, I have to send photos from my phone to PC as files to upload 2560px (via Telegram of-course). Would it be possible to improve the compression ratio, as 84% is terrible? And the last one propose - enable 2560px downloading if source has it instead of always using 1280px while no Large Photos enabled?

this doesn't belongs to telegram desktop bug tracker. instead to https://bugs.telegram.org

mrogin-technic commented 4 months ago

Would it be possible to at least add the Large Photos option for all clients, not only PC? Currently, I have to send photos from my phone to PC as files to upload 2560px (via Telegram of-course). Would it be possible to improve the compression ratio, as 84% is terrible? And the last one propose - enable 2560px downloading if source has it instead of always using 1280px while no Large Photos enabled?

this doesn't belongs to telegram desktop bug tracker. instead to https://bugs.telegram.org

Yes, this is a fundamental problem on telegram and should be reconsidered. For me, it is completely illogical why a lower resolution is used for photos than for videos.

ilya-fedin commented 4 months ago

Yes, this is a fundamental problem on telegram and should be reconsidered.

Please note that asking here for changes in other clients or on the server won't result in anything, this isn't an official place and no official body is reading this. Only the repo owner (tdesktop developer) and its community reading this tracker.

john-preston commented 4 months ago

I'm closing the ticket, because the way it can be done in TDesktop - it is already done, in Experimental settings. For a different requests, that include changes in other Telegram apps or on Telegram server, feel free to fill up a request on https://suggestions.telegram.org

QuAzI commented 4 months ago

It was https://bugs.telegram.org/c/15370 Issue about server-side recompression https://bugs.telegram.org/c/1058 And Large Photos proposal for Android https://bugs.telegram.org/c/26489