Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

i want to download images with pytelegrambotapi with good quality , but i cant

I want to download images with pytelegrambotapi with good quality,
I use this code, its ok and works, but it download images with bad quality.

@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)

what should i do ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The sent photo undergoes resizing and compression. If you wish to process the original photo as a file, you may manually send it as a document to the bot or utilize the sendDocument feature for that purpose.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading