2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Stefano Mtangoo
0

I don't think PIL can do this. The XPixelMap format is a text based C array and you could probably take bitmap information and create this array and save it. Presumably there are C utilities around that create XPM files, you should be able to run those from within Python.

One of the free picture programs that batch converts to and from the XPM format is PhotoMania from:
http://wareseeker.com/download/photomania-dx-6.73.rar/418074

Here is an example of a 5x5 red dot in XPM format ...

/* XPM */
static char * dot[] = {
"5 5 2 1",
". c None",
"X c Red",
"  X  ",
" XXX ",
"XXXXX",
" XXX ",
"  X  ",
};

Since it's text based, one can simply change the array element
"X c Red"
to
"X c Blue"
and get a blue dot.

BTW, PIL can read XPM files but not write them.

Edited by vegaseat: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.