BMP4 to BMP3 - changing alpha from black to white?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Steve

BMP4 to BMP3 - changing alpha from black to white?

Post by Steve »

Hi,

When I convert a 32-bit BMP to a 24-bit BMP the alpha channel displays as black in the
result. I'd like to change this to another colour (white).

It must be easy ... but after four hours of searching I'm still stuck. Can someone put me
out of my misery with a quick one liner.

Thanks, Steve.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: BMP4 to BMP3 - changing alpha from black to white?

Post by fmw42 »

I don't know much about bmp image, but see http://www.imagemagick.org/Usage/formats/#bmp

and also try

convert bmp32bit -background somecolor -flatten bmp24bit
Steve

Re: BMP4 to BMP3 - changing alpha from black to white?

Post by Steve »

Hi,

From the file format reference it's clear that IM is no fan of bmp file formats.

Fortunately I also have my reference image as a .png. I can convert this
to BMP3 and BMP4 without problem:

BMP3 on white background:

convert -size 256x256 xc:white infile.png -composite BMP3:outfile.bmp

BMP4 with alpha channel:

convert infile.png outfile.bmp

I'm sure there are better ways but I'll stick with this and helpfully keep my sanity.

Thanks, Steve.
Post Reply