[IMAGE-SIG] PIL 0.3a1 and xbm file formats

Piers Lauder piers@cs.su.oz.au
Mon, 21 Jul 1997 14:21:28 +1000


I'm having trouble reading some images saved in "xbm" format.

Most xbm format images can be opened ok, but there are a few
with extra #define lines at the top, which PIL doesn't like.

If I remove the extra #defines, the image loads:

	: s facemail ; python
	Python 1.4 (Jul 16 1997)  [GCC 2.7.2.2]
	Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
	>>> import Image
	>>> Image.open('/usr/local/lib/faces/au/oz/su/cs/gary/face.xbm')
	Traceback (innermost last):
	  File "<stdin>", line 1, in ?
	  File "/usr/local/lib/python1.4/local/Image.py", line 713, in open
	    raise IOError, "cannot identify image file"
	IOError: cannot identify image file
	>>> Image.open('/tmp/face.xbm')
	<XbmImageFile instance at 99d20>
	>>> ^D

	: s facemail ; diff /tmp/face.xbm /usr/local/lib/faces/au/oz/su/cs/gary/face.xbm
	2a3,4
	> #define gary_x_hot -1
	> #define gary_y_hot -1

	: s facemail ; sed 10q /usr/local/lib/faces/au/oz/su/cs/gary/face.xbm
	#define gary_width 48
	#define gary_height 48
	#define gary_x_hot -1
	#define gary_y_hot -1
	static char gary_bits[] = {
	   0x00, 0xfc, 0xff, 0xff, 0x07, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x0f, 0x00,
	   0x00, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x80, 0xff, 0x7f, 0xc1, 0x7f, 0x00,
	   0xc0, 0xff, 0x8f, 0x2a, 0xfd, 0x00, 0xc0, 0xff, 0x13, 0x80, 0xfe, 0x01,
	   0xe0, 0xff, 0x40, 0x20, 0xf5, 0x01, 0xe0, 0x17, 0x04, 0x08, 0xfa, 0x03,
	   0xe0, 0x01, 0x00, 0x80, 0xfa, 0x03, 0xf0, 0x16, 0x00, 0x00, 0xf4, 0x03,

I'm not sure if these are "standard" - but should the xbm loader ignore
additional #defines? Otherwise I'll amend my code to remove them before
passing them to PIL.

_______________
IMAGE-SIG - SIG on Image Processing with Python

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