Skip to content Skip to sidebar Skip to footer

Error Python Imaging Library

I'm doing a system of change of avatar using the Python Imaging Library, but I'm having problem in following error presented: client.changeAvatar(data) File 'C:\Users\Administrat

Solution 1:

Once you have your Image object, re-use it to make the different thumbnails.

Take a look at the Image.thumbnail() function, it's a little easier to use than just downsampling the original image.

import PIL, PIL.Image
from StringIO import StringIO

data = open('rose.jpg').read()

img = PIL.Image.open( StringIO(data) )
playerID = 123# write full image to filewithopen("%i.jpg" %(playerID), "wb") as f:
    f.write(data)

# using same image, make 100px thumbnail# TODO: use .thumbnail()
img.resize((100, 100), PIL.Image.ANTIALIAS
).save('%i_100.jpg' % playerID)

# make a 50px thumbnail
img.resize((50, 50), PIL.Image.ANTIALIAS
       ).save("%i_50.jpg" %playerID)

Post a Comment for "Error Python Imaging Library"