A PIL Question
Max Erickson
maxerickson at gmail.com
Sun Aug 14 14:41:12 EDT 2005
"Ray" <ray_usenet at yahoo.com> wrote in
news:1124040878.557813.311900 at g47g2000cwa.googlegroups.com:
>
> image = Image.Image()
>
> Anybody has any idea why this is the case?
>
Image.Image() isn't the way to get a new image object in PIL. Try
Image.new(), which needs at least mode and size arguments. You can get
those from your original image...
>>> from PIL import Image
(skip me loading an image into im)
>>> im
<PIL.JpegImagePlugin.JpegImageFile instance at 0x00A8A170>
>>> im.mode
'RGB'
>>> im.size
(510, 800)
>>> im2=Image.new(im.mode,im.size)
>>> seq=im.getdata()
>>> im2.putdata(seq)
Then do im2.show() and everything should be ok.
max
More information about the Python-list
mailing list