[PYTHON IMAGE-SIG] Should this work?

Zachary_Roadhouse@brown.edu Zachary_Roadhouse@brown.edu
Wed, 21 May 1997 17:19:43 -0400 (EDT)


While trying to play with conversion between PIL and Magick images, I
ran into the following problem:

def ImageToPIL(img):
    """Converts to a PIL Image"""
    
    import Image

    out = Image.new(img.mode,img.size)
    out.fromstring(img.tostring())

    return out

Since Magick and PIL images have similar interfaces this should
work for both.  When I try to do this with a PIL image of mode 'P', 
it breaks.  Is there a way to force a PIL image into 'RGB' mode
before conversion?  I would like to do this in order to convert
from a PIL image to a Magick image by:

img = Magick.image()
img.fromstring(pil.size[0],pil.size[1],pil.tostring())

I'm guessing that the palette stuff doesn't work. When will it?

                        --Zack

/---------------------------------------------------------------------
Zachary F. Roadhouse                               Home: (401)863-xxxx
Box 220, Brown University, Providence, RI 02912    Work: (401)863-2177
E-MAIL: Zachary_Roadhouse@brown.edu
WWW: http://www.techhouse.brown.edu/~zack

_______________
IMAGE-SIG - SIG on Image Processing with Python

send messages to: image-sig@python.org
administrivia to: image-sig-request@python.org
_______________