我想使用 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)
我该怎么办?
发送的照片经过调整大小和压缩。如果您希望将原始照片作为文件处理,您可以手动将其作为文档发送给机器人或利用
sendDocument
功能来实现此目的。