U
U
usiting2021-11-27 13:00:03
Python
usiting, 2021-11-27 13:00:03

How to save an image in BytesIO?

there is a code snippet from Telegram Bot

def decrypting(message):
        detector = cv2.QRCodeDetector()
        qr_image = message.photo
        bio = BytesIO()
        qr_image.save(bio, 'JPEG')
        bio.seek(0)
        data = detector.detectAndDecode(bio)
        bot.send_message(message.chat.id, f'QR code data: \n\n{data}')


an error occurs while running the function
61a2018e680f5949476412.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-11-27
@usiting

The photo attribute of the Message class is a list. Read the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question