Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an image stored in BMP format and would like to convert it to PNG using imagemagick.

I looked at the pixels in a hex viewer and noticed that they are stored in 32bpp, so there is an alpha channel. The transparent pixels have RGBA value (255, 255, 255, 0), and paint.NET is picking them up as white pixels probably because it doesn't expect BMP's to have transparent pixels?

Anyways, the command I used is

convert -alpha on -quality 95 in.bmp out.png

However, when I opened the resulting image in Paint.NET (which usually interprets transparent pixels properly), those transparent pixels were still white.

Am I converting the images incorrectly? I would like the pixels with an alpha value of 0 to appear transparent in the image editor that I commonly use.

share|improve this question

2 Answers 2

You discovered a bug in ImageMagick. This will be fixed in ImageMagick 6.8.7-9. I am one of the developers for ImageMagick and I just committed the fix to our SVN repository (http://trac.imagemagick.org/changeset/13867).

share|improve this answer
    
How do you know this? Any supporting info? –  Dave M Nov 30 '13 at 21:41
    
I apologize for the short answer. I am one of the developers for ImageMagick and I just committed the fix to our SVN repository. –  dlemstra Nov 30 '13 at 21:47
    
@dlemstra - that information would be better edited into your answer. –  ChrisF Nov 30 '13 at 21:48
    
Thanks, I'll try it out when it's released and get back to this question. –  MxyL Nov 30 '13 at 23:34
    
Just out of curiosity @Keikoku is there a link to the SVN repo we could see? Thanks for taking the time to provide this information, and for accurately disclosing your involvement with the project. –  nhinkle Dec 1 '13 at 0:05

It may not be an alpha channel. If it's a bitmap v4 format file, it can have an alpha channel. For earlier versions, it is still possible to store the pixels as 32 bits, but the top bit is reserved and always zero.

Here's an example of a 32 bit bmp with alpha Here's an example of a 32 bit bmp with no alpha

The example image in the comments has no alpha channel according to GIMP and identify -verbose the best you can do is make the white background transparent with

convert sample.bmp -transparent white alpha.png
share|improve this answer
    
I believe it is used as an alpha channel because not every pixel has zero for that byte, and if I parse it manually and treat it as an alpha channel, the resulting image has the correct transparent pixels. In that case, maybe imagemagick is not treating it as an alpha channel, so I would like to tell imagemagick to treat it as such? –  MxyL Sep 9 '13 at 17:04
    
Can you run identify -verbose on the file and look at the channel info? or post a link to the image itself –  parkydr Sep 9 '13 at 20:10
    
I made a BMP with alpha (with GIMP) and did convert alpha.bmp alpha.png and it worked ok. The png was transparent. –  parkydr Sep 10 '13 at 20:52
    
here is a sample bmp. –  MxyL Sep 11 '13 at 4:05
    
According to GIMP and identify, there is no alpha channel –  parkydr Sep 11 '13 at 16:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.