yowsup icon indicating copy to clipboard operation
yowsup copied to clipboard

Cannot send images

Open 2opremio opened this issue 13 years ago • 42 comments

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

2opremio avatar Dec 20 '12 19:12 2opremio

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'

2opremio avatar Dec 20 '12 20:12 2opremio

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.

luizping avatar Apr 12 '13 13:04 luizping

Just like luizping said, I managed to sent my image but the image never arrived for the receiver. Any updates on this?

engowen avatar Jul 06 '13 07:07 engowen

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.

xiaojxiao avatar Jul 25 '13 02:07 xiaojxiao

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.

shirioko avatar Jul 25 '13 07:07 shirioko

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

mrtass avatar Apr 25 '14 06:04 mrtass

You're not sending the thumbnail, therefor you're not receiving any.

shirioko avatar Apr 25 '14 06:04 shirioko

@shirioko would you mind post an example that would help lots of people thanks

mrtass avatar Apr 25 '14 07:04 mrtass

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

shirioko avatar Apr 25 '14 07:04 shirioko

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   

mrtass avatar Apr 25 '14 07:04 mrtass

What is limitations on sending images?

saeedghx68 avatar Apr 26 '14 12:04 saeedghx68

currently there are no limitations in whatsapp servers

CODeRUS avatar Apr 26 '14 12:04 CODeRUS

i guess it's the same like sending a message

mrtass avatar Apr 26 '14 12:04 mrtass

@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

kepeto avatar May 09 '14 12:05 kepeto

What error u getting

mrtass avatar May 09 '14 12:05 mrtass

@mrtass no error on sending, the thumbnail is not generated correctly only show white image screenshot_2014-05-09-20-11-15

kepeto avatar May 09 '14 13:05 kepeto

Mail me Mrtass at Hotmail. Com I'll give u full code

mrtass avatar May 09 '14 13:05 mrtass

you should use raw data, not base64 encoded one. and thumbnail should be generated from scaled down (i'm using 64x64) image ;)

CODeRUS avatar May 09 '14 14:05 CODeRUS

btw @CODeRUS the image is not received all the times do u have any idea of wat could be the reason ?

mrtass avatar May 09 '14 14:05 mrtass

something wrong in your code :)

CODeRUS avatar May 09 '14 14:05 CODeRUS