Page 1 of 1
Convert to 32-bit depth BMP
Posted: 2016-10-27T01:23:54-07:00
by wsielski
Hi I'm trying to convert png file to BMP 32-bit depth.
Unfortunately all my tests ends with 8-bit BMP file. What am I doing wrong?
Code: Select all
$ convert image.jpg -verbose test_clean.bmp
image.jpg=>test_clean.bmp JPEG 4032x3024 4032x3024+0+0 8-bit sRGB 36.58MB 0.640u 0:00.680
$ convert image.jpg -verbose -depth 32 test_clean32.bmp
image.jpg=>test_clean32.bmp JPEG 4032x3024 4032x3024+0+0 32-bit sRGB 36.58MB 0.690u 0:00.740
$ identify test_clean.bmp
test_clean.bmp BMP 4032x3024 4032x3024+0+0 8-bit sRGB 36.58MB 0.140u 0:00.140
$ identify test_clean32.bmp
test_clean32.bmp BMP 4032x3024 4032x3024+0+0 8-bit sRGB 36.58MB 0.140u 0:00.129
Re: Convert to 32-bit depth BMP
Posted: 2016-10-27T01:42:11-07:00
by snibgo
I think your are confusing two measurements. An image that has 8 bits/channel/pixel, and 4 channels, has 32 bits per pixel in total.
Re: Convert to 32-bit depth BMP
Posted: 2016-10-27T02:10:52-07:00
by wsielski
Well I'm not really sure then how to test if it's 8bit/24bit/32bit depth.
The result of generating and identifying 24bit generation returns same results:
Code: Select all
$ convert image.jpg -verbose -depth 24 test_clean24.bmp
image.jpg=>test_clean24.bmp JPEG 4032x3024 4032x3024+0+0 24-bit sRGB 36.58MB 0.750u 0:00.869
$ identify test_clean24.bmp
test_clean24.bmp BMP 4032x3024 4032x3024+0+0 8-bit sRGB 36.58MB 0.140u 0:00.149
Re: Convert to 32-bit depth BMP
Posted: 2016-10-27T02:20:46-07:00
by snibgo
In the first command, you ask for "-depth 24", which is 24 bits per channel per pixel (total 72 bits per pixel). IM gives you that. Then it saves to a BMP file.
Then you read back the BMP file, and now you have 8 bits/channel/pixel (total 24 bits/pixel).
Re: Convert to 32-bit depth BMP
Posted: 2016-10-27T02:39:35-07:00
by wsielski
But there is no difference between:
Code: Select all
$ identify test_clean32.bmp
test_clean32.bmp BMP 4032x3024 4032x3024+0+0 8-bit sRGB 36.58MB 0.140u 0:00.130
$ identify test_clean24.bmp
test_clean24.bmp BMP 4032x3024 4032x3024+0+0 8-bit sRGB 36.58MB 0.140u 0:00.129
Which I suppose should differ when test_clean32.bmp was created with '-depth 32' and test_clean24.bmp was created with '-depth 24'
Code: Select all
$ identify -format "%[bit-depth]\n" test_clean32.bmp
8
$ identify -format "%[bit-depth]\n" test_clean24.bmp
8
Re: Convert to 32-bit depth BMP
Posted: 2016-10-27T02:43:56-07:00
by snibgo
No. See above. "-depth 32" means 32 bits per channel per pixel, NOT a total of 32 bits.
Re: Convert to 32-bit depth BMP
Posted: 2016-10-27T09:00:27-07:00
by Jason S
BMP is limited to around 10 bits per channel (and more than 8 is rarely supported), so if you really want 32, you can't use BMP format. Assuming you want 32 bits per
pixel:
Most full-color BMP images have 24 bits per pixel, not 32. A 32-bit BMP could mean (1) there are 8 unused bits per pixel, or (2) there is an 8-bit alpha channel, or (3) all 32 bits are used by the color channels, for example R11/G11/B10 format. I think that ImageMagick only supports possibility (2) when writing BMP files.
I think that ImageMagick won't write a 32-bit BMP image unless it thinks there is an alpha channel, and for the usual BMPv3 format you also need "-define bmp3:alpha=true". Adding an alpha channel probably won't have any bad side effects, so you could try:
Code: Select all
$ convert rose: -alpha set -define bmp:format=bmp4 test.bmp
$ file test.bmp
test.bmp: PC bitmap, Windows 98/2000 and newer format, 70 x 46 x 32
or:
Code: Select all
$ convert rose: -alpha set -define bmp:format=bmp3 -define bmp3:alpha=true test.bmp
$ file test.bmp
test.bmp: PC bitmap, Windows 3.x format, 70 x 46 x 32
Re: Convert to 32-bit depth BMP
Posted: 2019-05-30T09:33:04-07:00
by edwpang
This works for me:
$ convert rose: -alpha set -define bmp:format=bmp3 -define bmp3:alpha=true test.bmp
$ file test.bmp
test.bmp: PC bitmap, Windows 3.x format, 70 x 46 x 32
But I don't why bmp4 one doesn't work.