Page 1 of 1
Preserve alpha/transparency when converting 32-bit PNG to BMP [Solved]
Posted: Thu Oct 21, 2021 12:49 am
by Defenestration
I want to convert a load of images in different formats (some with tranparency/alpha channels) to a single format whilst preserving the alpha/transparency. I chose BMP as the target format (but may change to PNG in the future).
As a simple test in using NConvert to do this, I have a 32-bit PNG image which I wish to convert to BMP whilst preserving alpha/transparency. I tried the following, but when the BMP file is viewed the transparent area is no longer transparent. I would expect the following to work, but it doesn't:
Code: Select all
nconvert.exe -out bmp 32bit_png_image_with_alpha_transparency.png
I noticed that it does work when converting it to webp format though:
Code: Select all
nconvert.exe -out webp 32bit_png_image_with_alpha_transparency.png
How can I make it work when converting to BMP ?
Same goes for when converting image to PNG, also whilst keeping alpha/transparency.
Ideally, I want one command which works for all input image files of different formats.
I was expecting this to be easy with NConvert, but either it's buggy, or I'm not using the correct command-line options.
Re: Preserve alpha/transparency when converting 32-bit PNG to BMP
Posted: Thu Oct 21, 2021 10:51 am
by cday
While waiting for a possible response from Pierre or the forum transparency expert XnTriq, you might try including the following term in your code:
I am no transparency expert but believe that an equivalent operation is currently required in the GUI versions of xnview software.
If you are ultimately unable to use a single code line for any source file format, using two or if necessary more lines in a batch file shouldn't be a significant hardship, should it?
Re: Preserve alpha/transparency when converting 32-bit PNG to BMP
Posted: Thu Oct 21, 2021 8:21 pm
by Defenestration
-32bits option doesn't work.
I'm amazed that this relatively simple feature is still not supported (and not just in XnView, but also in some other Image viewers), despite PNG and BMP being two popular formats. There are lots of other options for controlling what you want to happen during the conversion, but a simple conversion (with or without transparency) to another format should just do the obvious - ie. if source has transparency and dest support it, dest should end up with it, and look the same. If dest doesn't support transparency, then convert without transparency.
Using multiple commands to achieve this is no problem, if someone can show me the commands ?
But, it should be possible to just do the following, and get the expected result (ie. 32 bit BMP image with same transparency/alpha channel), as is the case when dest is WebP format:
Code: Select all
nconvert.exe -out bmp 32bit_png_image_with_alpha_transparency.png
Please can you implement this feature in both NConvert/XnConvert and XnView/XnView MP.
Re: Preserve alpha/transparency when converting 32-bit PNG to BMP
Posted: Fri Oct 22, 2021 1:05 pm
by xnview
could you post the output bmp?
Re: Preserve alpha/transparency when converting 32-bit PNG to BMP
Posted: Fri Oct 22, 2021 1:46 pm
by Defenestration
Thanks for looking into this...
Source PNG:

- 32bit_png_image_with_alpha_transparency.png (7.93 KiB) Viewed 7688 times
Converted to following BMP:

- 32bit_png_image_with_alpha_transparency_converted_to_bmp.bmp (30.99 KiB) Viewed 7688 times
...using following options. Transparent bit is white in converted BMP.
Code: Select all
nconvert.exe -out bmp 32bit_png_image_with_alpha_transparency.png
Re: Preserve alpha/transparency when converting 32-bit PNG to BMP
Posted: Fri Oct 22, 2021 2:29 pm
by xnview
the BMP file is 32bits RGBA
Re: Preserve alpha/transparency when converting 32-bit PNG to BMP
Posted: Fri Oct 22, 2021 8:11 pm
by Defenestration
Why is the part of the image surrounding the ball transparent in the PNG, but white in the BMP ?
How can I get the white bit to be transparent ?
Why doesn't NConvert convert it whilst preserving the transparent part (ie. so it looks just like the PNG source) ?
Re: Preserve alpha/transparency when converting 32-bit PNG to BMP
Posted: Sat Oct 23, 2021 6:59 am
by xnview
Defenestration wrote: Fri Oct 22, 2021 8:11 pm
Why is the part of the image surrounding the ball transparent in the PNG, but white in the BMP ?
How can I get the white bit to be transparent ?
Why doesn't NConvert convert it whilst preserving the transparent part (ie. so it looks just like the PNG source) ?
the alpha is preserved, many viewers don't support 32bits BMP, please check with XnView
Re: Preserve alpha/transparency when converting 32-bit PNG to BMP
Posted: Sat Oct 23, 2021 11:06 am
by Defenestration
You are right, Pierre.
Apologies for not testing properly, and jumping to conclusions.
This is a real plus for XnView/XnConvert, as most other apps do not handle this.