[Image-SIG] Re: System Error: unknown raw mode

Fredrik Lundh fredrik at pythonware.com
Fri Oct 8 22:41:03 CEST 2004


Frederik Fix wrote:

> I have a problem with the Image.tostring() method. When I call it on an
> Image create with Image.new() and mode "RGBX" I receive a System Error:
> unknown raw mode. When I call it with the "RGB" mode it works. Images
> loaded with Image.load() work without a problem. See below for a
> transcript.

>>>> i2 = Image.new("RGBA", (10,10))
>>>> s2 = i2.tostring("raw", "RGBX", 0, -1)
> Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>  File "/sw/lib/python2.3/site-packages/PIL/Image.py", line 439, in
>  tostring
>    e = _getencoder(self.mode, encoder_name, args)
>  File "/sw/lib/python2.3/site-packages/PIL/Image.py", line 323, in
>  _getencoder
>    return apply(encoder, (mode,) + args + extra)
> SystemError: unknown raw mode

what do you expect that line to do?

there's no tostring packer defined for RGBA->RGBX.  if you want to
store the pixels as 32-bit entities, just store them as is (RGBA instead
of RGBX).  if you want to get rid of the alpha, convert to RGB before
storing as RGBX.

</F> 





More information about the Image-SIG mailing list