[Image-SIG] tostring raw/RGB bitmap problem

Joe Connellan joec@mill.co.uk
Wed, 04 Sep 2002 16:31:05 +0100


I'm able to read in some BMP images using the following code

img = Image.open("blah.bmp")
img.tostring("raw", "RGB", 0, -1)

but on some other images - written by a different application (Shake
from Nothing Real) I get the following error

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python22\lib\lib-tk\Tkinter.py", line 1292, in __call__
    return apply(self.func, args)
  File "C:\dev\imageViewer\imageViewer.py", line 392, in loadCB
    self.importClip(fileList)
  File "C:\dev\imageViewer\imageViewer.py", line 272, in importClip
    self.imgData.append(img.tostring("raw", "RGB", 0, -1))
  File "C:\Python22\PIL\Image.py", line 354, in tostring
    e = _getencoder(self.mode, encoder_name, args)
  File "C:\Python22\PIL\Image.py", line 257, in _getencoder
    return apply(encoder, (mode,) + args + extra)
SystemError: unknown raw mode

how could it understand "RGB" as the raw mode for some bitmaps but not
others?

Has anyone come accross this before? any ideas on how I go about fixing
it?

Thanks

Joe