[Image-SIG] How to store image as black&white bmp (1-bit colorscheme)?

Fredrik Lundh fredrik at pythonware.com
Mon Feb 20 12:43:25 CET 2006


Alexander Belchenko wrote:

>I try to convert with PIL some of my black&white images from 24-bit bmp
> format to 1-bit bmp format. But anyway PIL save converted image as
> 24-bit bmp. How to save it as 1-bit? Is PIL support saving bmp as 1-bit?
>
> Here my code example:
>
> import Image
>
> im = Image.open('file-24bit.bmp')
> im.convert('1')
> im.save('file-1bit.bmp')
>
> But saved file anyway have 24-bit color.

like most PIL methods, convert returns the converted image.  try changing
your code to:

    im = im.convert('1')
    im.save('file-1bit.bmp')

</F> 





More information about the Image-SIG mailing list