cant convert bmp to png
cant convert bmp to png
Hello,
I have to convert via command line tool (convert.exe) bitmap generated in C++ to png
orignal bitmap are 32 bits, check here a sample : https://s3-eu-west-1.amazonaws.com/acce ... -47-09.bmp
as you can see , there is no problem to open this bmp is a browser, windows preview or photoshop, so I guess there s no particular problem with the specific file
I try various commands but all with the same result : I get a completly transparent image
convert image.bmp image.png > transparent
convert image.bmp -channel rgba image.png > transparent
convert image.bmp -channel rgb image.png > transparent
identify image.bmp
image.bmp BMP 640x480 640x480+0+0 8-bit sRGB 1.229MB 0.000u 0:
00.005
Any suggestions ?
I have to convert via command line tool (convert.exe) bitmap generated in C++ to png
orignal bitmap are 32 bits, check here a sample : https://s3-eu-west-1.amazonaws.com/acce ... -47-09.bmp
as you can see , there is no problem to open this bmp is a browser, windows preview or photoshop, so I guess there s no particular problem with the specific file
I try various commands but all with the same result : I get a completly transparent image
convert image.bmp image.png > transparent
convert image.bmp -channel rgba image.png > transparent
convert image.bmp -channel rgb image.png > transparent
identify image.bmp
image.bmp BMP 640x480 640x480+0+0 8-bit sRGB 1.229MB 0.000u 0:
00.005
Any suggestions ?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: cant convert bmp to png
The conversion works fine for me (IM 6.7.9-6, Windows 7).
What version of IM are you running?
What version of IM are you running?
snibgo's IM pages: im.snibgo.com
Re: cant convert bmp to png
Hi,
ImageMagick-6.8.0-Q16 on windows 7
ImageMagick-6.8.0-Q16 on windows 7
Re: cant convert bmp to png
@snibgo: better stay with this version. the png is transparent here (IM 6.8.0-4 Q16, Windows 7)
Re: cant convert bmp to png
The image is valid, and not transparent.
As a workaround, try
I think IM just assumes that all 32-bit BMP images use transparency. That's not right -- if anything, it should assume that they don't. Some BMP viewers try to guess, based on the contents of the image.
As a workaround, try
Code: Select all
convert image.bmp -alpha off image.png
Re: cant convert bmp to png
It seems that recent versions of IM have mixed up opacity and transparency in BMP.
Testing with IM-6.8.0-5 from SVN:
"convert rose: -matte rose.bmp" creates a transparent image, when viewed by another app.
Then "convert rose.bmp rose.png" creates the original opaque rose image.
[edit] The current IM-7.0.0 alpha behaves the same way.
Testing with IM-6.8.0-5 from SVN:
"convert rose: -matte rose.bmp" creates a transparent image, when viewed by another app.
Then "convert rose.bmp rose.png" creates the original opaque rose image.
[edit] The current IM-7.0.0 alpha behaves the same way.
Re: cant convert bmp to png
I'm not seeing this problem. With IM 6.8.0-4, I get an image that uses 0xff as the transparency/opacity value. As far as I know, that's correct (opaque).glennrp wrote:"convert rose: -matte rose.bmp" creates a transparent image, when viewed by another app.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: cant convert bmp to png
I believe your image is malformed and reports alpha=0 for an opaque image. An opaque image should have alpha=255 (1)
For example:
With PNG, this is correct:
convert rose: -alpha opaque rose_tmp.png
identify -verbose rose_tmp.png
Image: rose_tmp.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 70x46+0+0
Units: Undefined
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 1-bit
...
Alpha:
min: 255 (1)
max: 255 (1)
mean: 255 (1)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
With BMP, this is correct:
convert rose: -alpha opaque rose_tmp.bmp
identify -verbose rose_tmp.bmp
Image: rose_tmp.bmp
Format: BMP (Microsoft Windows bitmap image)
Class: DirectClass
Geometry: 70x46+0+0
Units: PixelsPerCentimeter
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 1-bit
...
Alpha:
min: 255 (1)
max: 255 (1)
mean: 255 (1)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
But with your opaque bmp, I get:
identify -verbose KinectSnapshot-04-47-09.bmp
Image: KinectSnapshot-04-47-09.bmp
Format: BMP (Microsoft Windows bitmap image)
Class: DirectClass
Geometry: 640x480+0+0
Units: PixelsPerCentimeter
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 1-bit
...
Alpha:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
All zeros for alpha normally means perfectly and fully transparent.
For example:
With PNG, this is correct:
convert rose: -alpha opaque rose_tmp.png
identify -verbose rose_tmp.png
Image: rose_tmp.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 70x46+0+0
Units: Undefined
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 1-bit
...
Alpha:
min: 255 (1)
max: 255 (1)
mean: 255 (1)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
With BMP, this is correct:
convert rose: -alpha opaque rose_tmp.bmp
identify -verbose rose_tmp.bmp
Image: rose_tmp.bmp
Format: BMP (Microsoft Windows bitmap image)
Class: DirectClass
Geometry: 70x46+0+0
Units: PixelsPerCentimeter
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 1-bit
...
Alpha:
min: 255 (1)
max: 255 (1)
mean: 255 (1)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
But with your opaque bmp, I get:
identify -verbose KinectSnapshot-04-47-09.bmp
Image: KinectSnapshot-04-47-09.bmp
Format: BMP (Microsoft Windows bitmap image)
Class: DirectClass
Geometry: 640x480+0+0
Units: PixelsPerCentimeter
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 1-bit
...
Alpha:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
All zeros for alpha normally means perfectly and fully transparent.
Re: cant convert bmp to png
KinectSnapshot-04-47-09.bmp technically does not have an alpha channel. Its Type is identified incorrectly.
http://msdn.microsoft.com/en-us/library ... 85%29.aspx says
http://msdn.microsoft.com/en-us/library ... 85%29.aspx says
"The value for blue is in the least significant 8 bits, followed by 8 bits each for green and red. The high byte in each DWORD is not used."
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: cant convert bmp to png
I am no expert, but there are several versions of bmp. See http://www.imagemagick.org/Usage/formats/#bmp
If you do not know which version you are using, then try
convert BMP2:image.bmp image.png
or
convert BMP3:image.bmp image.png
If that fails, then report this issue on the Bugs forum and reference back to this topic. Be sure to identify your version of IM and platform.
P.S. In the mean time, you can use
convert KinectSnapshot-04-47-09.bmp -alpha off KinectSnapshot-04-47-09.png
to get a non-transparent resulting png.
If you do not know which version you are using, then try
convert BMP2:image.bmp image.png
or
convert BMP3:image.bmp image.png
If that fails, then report this issue on the Bugs forum and reference back to this topic. Be sure to identify your version of IM and platform.
P.S. In the mean time, you can use
convert KinectSnapshot-04-47-09.bmp -alpha off KinectSnapshot-04-47-09.png
to get a non-transparent resulting png.
Re: cant convert bmp to png
You are using the same buggy codec when you use "identify". Naturally it's self-consistent, Use some other application to find out what's really in the image.fmw42 wrote:I believe your image is malformed and reports alpha=0 for an opaque image. An opaque image should have alpha=255 (1)
With BMP, this is correct:
convert rose: -alpha opaque rose_tmp.bmp
identify -verbose rose_tmp.bmp
This situation has existed for a while.
[edit]So far I've tested back to 6.4.8-10 which is correct.
[edit]I misread my diagnostics about 6.6.0; it's OK.
6.7.9-9 is OK and 6.8.0-1 is incorrect.