Skip to content
This repository has been archived by the owner on Jun 2, 2019. It is now read-only.

sendPhoto doesn't send image encoded anymore #177

Closed
andreasalvi opened this issue Nov 13, 2016 · 2 comments
Closed

sendPhoto doesn't send image encoded anymore #177

andreasalvi opened this issue Nov 13, 2016 · 2 comments

Comments

@andreasalvi
Copy link

Hello,
I've this code. frame is a Mat variable of opencv that contains an image

img_str = cv2.imencode('.jpg', frame)[1].tostring()
bot.sendPhoto(chat_id,['image.jpg', img_str])

I used this code some months ago and all worked fine but now don't.

@fedebecat
Copy link

We managed overcome this issue by using

import StringIO
bot.sendPhoto(chat_id,('image.jpg', StringIO.StingIO(img_str)))

@thalesmaoa
Copy link

thalesmaoa commented Dec 4, 2018

Its not working here. I have a frame, mat numpy, and just want to send with telepot.

In [10]: cap_ch11 = cv2.VideoCapture(ch11_url)                                  

In [11]: ret, frame = cap_ch11.read()                                           

In [12]: img_str = cv2.imencode('.jpg', frame)[1].tostring()                    

In [13]: bot.sendPhoto(chat_id,('image.jpg', StringIO.StringIO(img_str)))       
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-13-44c7306ef45c> in <module>
----> 1 bot.sendPhoto(chat_id,('image.jpg', StringIO.StringIO(img_str)))

NameError: name 'bot' is not defined

In [14]: import io                                                              

In [15]: bot.sendPhoto(chat_id,('image.jpg', io.StringIO(img_str))) 
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-21-010b054911d2> in <module>
----> 1 bot.sendPhoto(chat_id,('image.jpg', io.StringIO(img_str)))

TypeError: initial_value must be str or None, not bytes

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants