[Image-SIG] BMP Palettes

Thomi Richards thomi@thomi.imail.net.nz
Wed, 13 Nov 2002 12:18:58 +1300


> I believe you can use the convert() method to convert
> a 24 bit bmp to an 8 bit bmp.
> 
> im = Image.open("x.bmp")   # open 24 bit bmp
> im2 = im.convert("P")      # convert to P mode (8 bit)
> im2.save("newbmp.bmp")     # save new 8 bit bmp
> 
> # new image im2 is 8 bit
> 
> But this doesn't solve your problem about using
> another bmp's palette.

you can actually do this:

inimage = Image.open('palette.bmp')
outimage = Image.open('convert.bmp')

outim = outimage.convert('P')
outim.palette = inimage.palette

outim.save('converted.bmp')


the only problam with this is that it doesn't do it very well. I decided
to read every pixel in the file to convert, and used my own algorithm to
convert the colors. 

I'll let you know how i get on :-)

-- 
Lord, what fools these mortals be!
 -- midsummer nights dream.
Thomi Richards,
thomi@imail.net.nz