0
votes

as it seems PIL does not support RGBA .bmp files.

When I save the Image the transparent pixels get converted into black ones.

All that is possible is to save the Image as .png or something else but i really need it as a .bmp so is there any other way to create a RGBA bmp file in python?

1
Consider simply writing the data yourself into the very simple PAM format en.m.wikipedia.org/wiki/Netpbm#PAM_graphics_format and then using ImageMagick afterwards to convert that to PNG or something else that supports transparency - simple as convert image.pam result.png. - Mark Setchell
BMP is also a fairly simple format itself (especially if all you need to care for is 32 bit RGBA values), so if you go down that route, you might as well just write the BMP format directly. - Harald K

1 Answers

1
votes

Quoting Wikipedia:

An integrated alpha channel has been introduced with the undocumented BITMAPV3INFOHEADER and with the documented BITMAPV4HEADER (since Windows 95) and is used within Windows XP logon and theme system as well as Microsoft Office (since v2000); it is supported by some image editing software, such as Adobe Photoshop since version 7 and Adobe Flash since version MX 2004 (then known as Macromedia Flash). It is also supported by GIMP, Google Chrome, Microsoft PowerPoint and Microsoft Word.

For compatibility reasons, most applications use the older DIB headers for saving files.

It appears that ImageMagick supports the RGBA .bmp format. Saving a file as PNG and then converting, or using ImageMagick bindings instead of PIL, are among your options.