tgalal / yowsup

The WhatsApp lib
GNU General Public License v3.0
7.06k stars 2.23k forks source link

Corrupted profile pictures (Windows) #24

Closed sakya closed 9 years ago

sakya commented 11 years ago

The contact_getProfilePicture call downloads a corrupted jpeg (I tried with almost every contact I have in whatsapp). I'm using the module on Windows with python 2.6.4

CODeRUS commented 11 years ago

this is impossible

sakya commented 11 years ago

Why it's impossible? Here's an image downloaded with contact_getProfilePicture that at least can be viewed (the others cannot be even opened) http://www.freeimagehosting.net/t/gbei5.jpg

CODeRUS commented 11 years ago

because whole Wazapp project working on Yowsup and pictures are always correct. This can be only problem on your side, nothing related to Yowsup.

sakya commented 11 years ago

Did you try the module on Windows? Maybe it's os related. What problem should I have "on my side"? I just call the method and wait for the callback, and the file that is downloaded is that.

CODeRUS commented 11 years ago

even if it OS or Py version related its cant be related to Yowsup anyway. in every way you can debug it and investigate where problem. is you developer or not?

sakya commented 11 years ago

Ok, thanks for your help. I thought a bug tracking system was to submit bugs.

sakya commented 11 years ago

To save the image the file must be opened for binary output "wb". This fix the problem.

def createTmpFile(self, identifier ,data):
    tmpDir = "/tmp"

    filename = "%s/wazapp_%i_%s" % (tmpDir, randrange(0,100000) , hashlib.md5(identifier).hexdigest())

    tmpfile = open(filename, "wb")
    tmpfile.write(data)
    tmpfile.close()

    return filename
sakya commented 11 years ago

I'd also suggest to use tempfile.gettempdir() to get the temporary dir instead of the hard coded /tmp. It should return /tmp on linux (probably also on Harmattan) and the current user temporary dir on windows.

tgalal commented 9 years ago

fixed