I think I may have found an issue with writing a DIB.
I load an image that is basically an 8bit monochrome image.
Image reports the depth as 8, greyscale and monochrome.
I make sure that the image is marked as not monochrome as I want to create a DIB that is 8bit's (not 1 bit depth) as follows:
image.monochrome( false );
image.type( PaletteType );
image.classType( PseudoClass );
However in dib.c, WriteDIBImage:
The parameter image_info is ignored.
which means that the lines around 1185 are executed instead of obeying what is in image_info.
if (characteristics.monochrome)
dib_info.bits_per_pixel=1;
In fact the settings in image_info are not used very much at all in this method.
I don't know enough about GraphicsMagik to known if this is expected behaviour. However I would expect if I say that the image is not monochrome then WriteDIBImage should respect my settings.
I do need to also write DIB's with 1bit depth.
Version of GraphicsMagick: 1.3.23
It is quite common to convert an image from one format/type to another. Due to this, the image_info depth value may be a value in the range of 1 to 64 obtained from some other file format, or it may be specified by the user (using -depth parameter) and may be a value in the range of 0 to 18446744073709551615. Currently there is no "memory" of the format that the image came from (if it came from a format).
In the normal case, it is reasonable to write the output file in as compact a sub-format as possible.
The definition of monochrome is "a photograph or picture developed or executed in black and white or in varying tones of only one color." so the input image is indeed already monochrome.
GraphicsMagick attempts to detect monochrome images whenever there is no cost to do so. It is very tenacious at doing so since there is such a huge win for file sizes.
I am not seeing a way to succeed at this without adding a special option to specify the colormap index storage size.
Mercurial changeset 17909:88ac0115762a modifies the image monochrome method to set the Image is_monochrome flag to false if it is already set. This may allow this re-arranging of your settings to provide the desired result:
I will mark this issue closed. Please let me know if it does not help.