List Info

Thread: PIL Programming Questions




PIL Programming Questions
user name
2006-08-18 23:26:50
I just finished a PIL program and I feel like there may have
been more
efficient ways to do things I did "by hand" with
the raw data. Can
someone enlighten me?

1. I wanted to take 24 bit data, count the colours and make
an 8-bit BMP
if there are fewer than 256 colours. My brute force solution
required me
to build the palette by hand from the data and rewrite the
data one
pixel at a time. (a simple '.convert("P")'
seems to use an arbitrary
palette or something???)

2. I wanted to pad a bitmap by adding some space to the
right and
bottom. I did this by creating a new one and pasting the old
one into
it.

3. I wanted to convert every occurrence of one colour to
another. I
walked each pixel.

I also could not figure out how to get to a 4-bit BMP. I
inferred from
the documentation that this just isn't possible with out of
box PIL.

Overall: PIL really rocks.

 Paul Prescod
_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )