Is it a bug when convert *.bmp -colorspace Gray *.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

Re: Is it a bug when convert *.bmp -colorspace Gray *.bmp ?

Post by fmw42 »

I believe that all images created or converted within IM will actually have 3 channels, even if they are all the same grayscale channel. Thus the filesize will not change as you still have 3 channels and not one channel.

The commands

convert <inflle> -colorspace Gray <outfile>

and

convert <infile> -type Grayscale <outfile>

will still create a 3-channel image, but all 3 channels will be the same grayscale image.

I don't know of any way to save a single channel image within IM. If you import a single channel image into IM, as soon as you process it, it will become 3 channels.

Someone else may be able to correct me on this, if I am wrong.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Is it a bug when convert *.bmp -colorspace Gray *.bmp ?

Post by anthony »

If the image file format, and the IM format 'coder' module can handle a gray image. then the -type GrayScale should save the image with a single gray channel.

-colorspace is the in memory representation. With IM this basically makes each RGB channels all the same to 'kludge' a gray image, while allowing most operators to treat it as a simple 3 channel RGB image. Make sthe programming easier.

-type will first ensure the image is greyscale (just before saving, or when reading in an image) and then ask the coder module to save it as grayscale if it can. It is the file 'type' format of the image.

See IM Examples...
http://imagemagick.org/Usage/basics/#colorspace
http://imagemagick.org/Usage/basics/#type
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply