possible bug with alpha channel in bmp

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug with alpha channel in bmp

Post by fmw42 »

IM 6.5.9-10 Q16 Mac OSX Tiger.

Trying to convert a png with alpha channel to bmp with alpha channel. This page http://www.imagemagick.org/Usage/formats/#bmp seems to imply that bmp supports 32-bit image (24 rgb + 8 alpha).

"The presence of any transparency controls whether it uses a 24 (RGB) or 32
bit (RGBA) format BMP image. You can use "+matte" to turn off transparency
in an image."

I tried

convert logo: -resize 50% -transparent white logo2t.png

convert logo2t.png -channel rgba -alpha on -depth 8 logo2t.bmp

but no alpha channel is visible although there appears to be alpha in the verbose info.

Is this correct? Am I misunderstanding something?

Thanks

Fred


P.S. The alpha channel in the png seems to backwards.

convert logo: -resize 50% -transparent white logo2t.png

This looks fine. But

identify -verbose logo2t.png
...
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 1-bit
Channel statistics:
Red:
min: 0 (0)
max: 65279 (1)
mean: 228.346 (0.895475)
standard deviation: 68.9325 (0.270324)
kurtosis: 4.60678
skewness: -2.49081
Green:
min: 23 (0.0901961)
max: 65279 (1)
mean: 229.039 (0.898191)
standard deviation: 60.8313 (0.238554)
kurtosis: 3.02552
skewness: -2.15154
Blue:
min: 24 (0.0941176)
max: 65279 (1)
mean: 232.265 (0.910842)
standard deviation: 53.6033 (0.210209)
kurtosis: 4.29012
skewness: -2.32609
Alpha:
min: 255 (1)
max: 0 (0)
mean: 52.8793 (0.20737)
standard deviation: 103.383 (0.405423)
kurtosis: 0.0839255
skewness: -1.44358

Min should be 0 and Max should be 255
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug with alpha channel in bmp

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.6.0-0 Beta available by sometime tomorrow. Thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug with alpha channel in bmp

Post by fmw42 »

just to be clear, is that both problems? the bmp problem and the verbose info problem?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug with alpha channel in bmp

Post by fmw42 »

This problem does not seem to be fixed in IM 6.6.0-0 Q16 Mac OSX Tiger (per the changelog)

convert logo: -resize 50% -transparent white logo2t.png
convert logo2t.png -channel rgba -alpha on -depth 8 logo2t.bmp

but no alpha channel is visible when displayed, although there appears to be alpha in the verbose info.

identify -verbose logo2t.png
Image: logo2t.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 320x240+0+0
Resolution: 72x72
Print size: 4.44444x3.33333
Units: Undefined
Type: TrueColorMatte
Endianess: Undefined
Colorspace: RGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 1-bit
Channel statistics:
Red:
min: 0 (0)
max: 255 (1)
mean: 228.346 (0.895475)
standard deviation: 68.9325 (0.270324)
kurtosis: 4.60678
skewness: -2.49081
Green:
min: 23 (0.0901961)
max: 255 (1)
mean: 229.039 (0.898191)
standard deviation: 60.8313 (0.238554)
kurtosis: 3.02552
skewness: -2.15154
Blue:
min: 24 (0.0941176)
max: 255 (1)
mean: 232.265 (0.910842)
standard deviation: 53.6033 (0.210209)
kurtosis: 4.29012
skewness: -2.32609
Alpha:
min: 255 (1)
max: 0 (0)
mean: 52.8793 (0.20737)
standard deviation: 103.383 (0.405423)
kurtosis: 0.0839255
skewness: -1.44358


Two problems are apparent.

1) On Q16, I am getting min,max,mean in range of 0-255 and I thought it should have been 0-65535

2) The min of the alpha channel is 255 and not zero and the max is zero and not 65535.

Thanks

Fred
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug with alpha channel in bmp

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.6.0-1 Beta available by sometime tomorrow. Thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug with alpha channel in bmp

Post by fmw42 »

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

Re: possible bug with alpha channel in bmp

Post by fmw42 »

IM 6.0.0-1 Q16 Mac OSX Tiger

convert logo: -resize 50% -transparent white logo2t.png
convert logo2t.png show:

show: looks fine for the transparent png image

and viewing logo2t.png (in Mac Preview) shows a clear alpha channel / transparency with checkerboard behind the transparent parts.



convert logo2t.png -channel rgba -alpha on -depth 8 logo2t.bmp

but viewing logo2t.bmp (in Mac Preview) still shows no transparency although the -verbose info seems to indicate it is there

Alpha:
min: 0 (0)
max: 255 (1)
mean: 202.121 (0.79263)
standard deviation: 103.383 (0.405423)
kurtosis: 0.0839255
skewness: -1.44358


and

convert logo2t.bmp -alpha extract logo2t_alpha.bmp

shows a resonable alpha channel.

However

convert logo2t.bmp show:

show: here does show a reasonable transparency with checkerboard behind it. (but display logo2t.bmp shows the background window or desktop behind the transparency and not the checkerboard.)

So it appears that the problem now is simply in Mac Preview of transparent bmp images. Interestingly, neither Photoshop nor GraphicConverter display the transparency at all. Only IM seems to recognize and display it correctly
Post Reply