我想用 pytelegrambotapi 下载高质量的图像,但我不能

问题描述 投票:0回答:1

我想使用 pytelegrambotapi 下载高质量的图像, 我使用这个代码,它可以正常工作,但它下载的图像质量很差。

@bot.message_handler(content_types=['document', 'photo', 'audio', 'video', 'voice'])
def addfile(message):
    
    if message.photo:
        photo = bot.get_file(message.photo[0].file_id)
        photo_path = photo.file_path
        photo_id = photo.file_id
        photo_type = photo.file_path.split('.')[-1]

        
        file = bot.download_file(photo_path)
        with open(photo_id + "." + photo_type, "wb") as code:
            code.write(file)

我该怎么办?

python telegram-bot python-telegram-bot py-telegram-bot-api
1个回答
0
投票

发送的照片经过调整大小和压缩。如果您希望将原始照片作为文件处理,您可以手动将其作为文档发送给机器人或利用

sendDocument
功能来实现此目的。

© www.soinside.com 2019 - 2024. All rights reserved.