keep 8-bit depth grayscale colorspace for output BMP

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
a1s2d3f4

keep 8-bit depth grayscale colorspace for output BMP

Post by a1s2d3f4 »

I just started using imagemagick.

With command-line "convert" utility, I am trying to append two images together and have the output file be in the same format as the input images.

My two input images are grayscale (8-bit) BMP images.
(They are 320x480 pixels each, so that's exactly the number of bytes that is contained in the data).

If I do
convert <first_image> <second_image> -color 256 <output_file>, I get an image that's somehow only 144KB (instead of the expected 302KB), while the image properties (in windows) state that it is a "32-bit" image.

If I use identify for my input images I get:
...1.bmp BMP 320x480 320x480+0+0 PseudoClass 256c 8-bit 151.053kb

I don't know what is "PseudoClass", but how do I get my output image to be that type as well?

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

Re: keep 8-bit depth grayscale colorspace for output BMP

Post by fmw42 »

try

convert <first_image> <second_image> -colorspace Gray <output_file>
a1s2d3f4

Re: keep 8-bit depth grayscale colorspace for output BMP

Post by a1s2d3f4 »

I have tried it. -colorspace Gray option doesn't seem to change anything for me. The output bmp is 24bit.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: keep 8-bit depth grayscale colorspace for output BMP

Post by fmw42 »

Do each image separately,

convert image1 -colorspace Gray outimage1
confert image2 -colorspace Gray outimage2
a1s2d3f4

Re: keep 8-bit depth grayscale colorspace for output BMP

Post by a1s2d3f4 »

Converting like you said, creates output images that are smaller in byte size (i.e. from 152KB down to 89KB).
What amazes me, however, is that the quality of the image doesn't degrade.

As I said, my images are 320x480 (=153600bytes), with 8bits of resolution for each pixel. Now, somehow it is almost 1/2 that size, and yet the image quality is still, seemingly at 8 bits. What is going on?
a1s2d3f4

Re: keep 8-bit depth grayscale colorspace for output BMP

Post by a1s2d3f4 »

Does anyone know (re: question in my reply above)?
Post Reply