Telegram.Bot icon indicating copy to clipboard operation
Telegram.Bot copied to clipboard

Send Image with Compression

Open sorenaa opened this issue 10 years ago • 8 comments

Hi, how can send photo with compression?

sorenaa avatar Jun 12 '16 15:06 sorenaa

what do you mean by 'compression'? HTTP compression?

MrRoundRobin avatar Jun 12 '16 21:06 MrRoundRobin

Hi @MrRoundRobin, thanx for replay When you want to send e photo by "Desktop Telegram Client" you have 2 options:

  • without compression
  • with compression

If you send photo without compression, receiver client must manually download photo and view preview, but when you send photo "with compression" receiver client automatically download it and can view photo preview. New, I want send photo and want client directly can view photo preview (without click and download manually)

sorenaa avatar Jun 13 '16 06:06 sorenaa

I think he mean the like the way when a person use from telegram Desktop client, and Drag a photo the chat, then it can be choosed through "Send with compression" and "Send without compression".

So, if you mean this, you can check if a Photo size is more than specific size (which i dont know whats the max size for sending a photo with a bot maybe 10MB) then you Make a compression with a compression method, after that if the file size still is more than 10MB, send it through SendDocumentAsync method instead.

Update: Yes seems he exactly meant that i didnt read last message first, and plus to this, @MrRoundRobin Can you tell whats the max size possible for SendPhotoAsync, coz in telegram documentation not said anything about it. Also i tested and choosed 12MB photo and occured an exception with this message "PHOTO_SAVE_FILE_INVALID".

D4NTESPARDA avatar Jun 13 '16 07:06 D4NTESPARDA

@D4NTESPARDA I also don't know. you can ask @BotSupport to include in docs.

MrRoundRobin avatar Jun 13 '16 07:06 MrRoundRobin

@D4NTESPARDA I also don't know. you can ask @BotSupport to include in docs.

@MrRoundRobin I asked em, as i guessed they said it`s around 10MB, but i asked again for the accurate size and no answer still.

D4NTESPARDA avatar Jun 14 '16 11:06 D4NTESPARDA

When you use the SendPhoto method, it seems to automatically send it as an image (ie "with compression") and when you use the SendDocument methoid, it seems to send the full file (ie "without compression"). For example if you send a gif you must send it using SendDocument in order for them to get a playable gif on the other end.

ScottRFrost avatar Jun 14 '16 13:06 ScottRFrost

When you use the SendPhoto method, it seems to automatically send it as an image (ie "with compression") and when you use the SendDocument methoid, it seems to send the full file (ie "without compression"). For example if you send a gif you must send it using SendDocument in order for them to get a playable gif on the other end.

sure it do that, but i think he meant a separate way coz for some large photos it can't compress em lower than about 10MB, but ofc when you send a large size photo with SendPhoto method, it compress that it self and break to n array of type PhotoSize and just send [length-2]th of the array.

D4NTESPARDA avatar Jun 15 '16 07:06 D4NTESPARDA

Actually, i believe its quite simple. if you send the photo via SendPhoto it should compress it, if you send it via SendDocument it won't be compressed. @sorenaa EDIT: sorry for just repeating what others said, but that's just the way it is. I tested it.

Olfi01 avatar Jul 02 '17 10:07 Olfi01