Cannot send images
I m trying to mimic this example from WhatsAPI:
https://github.com/venomous0x/WhatsAPI/issues/51
By making the following call in CmdClient.py:
self.methodsInterface.call("message_imageSend",(self.jid,"http://www.anony.ws/i/2012/10/15/JKetE.jpg","JKetE.jpg",270038,open("/Users/fons/thumb.jpgb64",'r').read()))
which worked nicely under whatsapi the last time I tried. However, I get the following error:
ignored toString call, probably encountered byte
ignored toString call, probably encountered byte
Unhandled exception in thread started by >
Any tips on how to make it work? (sending textual messages works without problems)
Thanks in advance
OK, by ensuring that all arguments are strings the image gets sent, that is, by changing the call to:
self.methodsInterface.call("message_imageSend",(self.jid,"http://www.anony.ws/i/2012/10/15/JKetE.jpg","JKetE.jpg","270038",str(open("/Users/fons/thumb.jpgb64",'r').read())))
But the thumbnail I attach doesn't seem to get sent (a different one is) plus I get the following error:
Traceback (most recent call last): File "/Users/fons/yowsup/src/Examples/CmdClient.py", line 78, in onMessageSent formattedDate = datetime.datetime.fromtimestamp(self.sentCache[messageId][0]).strftime('%d-%m-%Y %H:%M') KeyError: '1356034787-1'
i duplicated EchoClient.py, and changed the line:
self.methodsInterface.call("message_send"...
to
self.methodsInterface.call("message_imageSend", (self.jid, self.url, self.name, self.size, str(open(self.preview).read())))
I got Message Sent, but didn't receive the image.
Just like luizping said, I managed to sent my image but the image never arrived for the receiver. Any updates on this?
It seems like you can only send images storing at WhatsApp server. I have tried some image urls, such as "https://mms837.whatsapp.net/d/zqga14Oo324uQMhl9Y_BAgTrqss/AjpsQZcsrnupZ2Ig8-WM8L9opgrUlaqiNRYbwMQNSRgc.jpg" and it worked.
WhatsAPI has added functionality which downloads the file before uploading it to WhatsApp. You can only send images which you have uploaded to WhatsApp. I think yowsup only supports local file uploads.
hello i'm implementing the method to send an image, upload and everything is working and i am receving the image on my mobile but no preview can anyone please tell me if image preview is possible or if i'm doing something wrong ? thats my code below:
self.methodsInterface.call("message_imageSend", (self.jid, url, name,str(statinfo.st_size), url ))
You're not sending the thumbnail, therefor you're not receiving any.
@shirioko would you mind post an example that would help lots of people thanks
I don't know python, so no.
Open the image, resize it to max 100*100, fetch its raw data (byte array) and include it in your sendImage call.
I've read so many stories about how awesome python is and all that, you probably have an image manipulation library which you can import to resize your image to a thumbnail.
Like the PIL: http://www.daniweb.com/software-development/python/code/216637/resize-an-image-python
thanks alot it worked you dont need to resize the picture just pass the url there here is my code:
def doSendImage(self, url):
print("Sending message_image")
statinfo = os.stat(self.path)
name=os.path.basename(self.path)
msgId = self.methodsInterface.call("message_imageSend", (self.jid, url, name,str(statinfo.st_size),self.createThumb()))
self.sentCache[msgId] = [int(time.time()), self.path]
def createThumb(self):
with open(self.path, "r") as imageFile:
str = base64.b64encode(imageFile.read())
print str
return str
What is limitations on sending images?
currently there are no limitations in whatsapp servers
i guess it's the same like sending a message
@mrtass i mix your code with @SamsonBox at post #178 but dont work
def doSendImage(self, url):
print("Sending message_image")
statinfo = os.stat(self.path)
name=os.path.basename(self.path)
msgId = self.methodsInterface.call("message_imageSend", (self.jid, url, name, str(statinfo.st_size), self.createThumb()))
self.sentCache[msgId] = [int(time.time()), self.path]
def createThumb(self):
with open(self.path, "r") as imageFile:
str = base64.b64encode(imageFile.read())
print str
return str
What error u getting
@mrtass no error on sending, the thumbnail is not generated correctly only show white image

Mail me Mrtass at Hotmail. Com I'll give u full code
you should use raw data, not base64 encoded one. and thumbnail should be generated from scaled down (i'm using 64x64) image ;)
btw @CODeRUS the image is not received all the times do u have any idea of wat could be the reason ?
something wrong in your code :)