Imagemagick Cannot Write Indexed 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
mkubilus
Posts: 4
Joined: 2012-12-10T19:29:03-07:00
Authentication code: 6789

Imagemagick Cannot Write Indexed BMP

Post by mkubilus »

Imagemagick will no longer create BMP images with an indexed color map. In 6.6.9-7 if I had an indexed BMP file and ran a convert operation, the result would be another indexed BMP file. In 6.7.7-10 the resulting BMP is *always* a non-indexed version. Same results with 6.8.0-8.

Steps to reproduce:

$ convert in.bmp out.bmp

Taking an indexed image of other file types such as a GIF and converting to a BMP also result in a non-indexed BMP. Taking an indexed BMP and converting to a GIF results in a properly indexed GIF, however.

It's as if Imagemagick has lost the ability to create an indexed BMP file.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagemagick Cannot Write Indexed BMP

Post by fmw42 »

try

convert in.bmp -type palette out.bmp
or
convert in.bmp -type palette BMP3:out.bmp
or
convert in.bmp -type palette BMP2:out.bmp
mkubilus
Posts: 4
Joined: 2012-12-10T19:29:03-07:00
Authentication code: 6789

Re: Imagemagick Cannot Write Indexed BMP

Post by mkubilus »

Thanks for the response!

'convert in.bmp -type palette BMP3:out.bmp'
and
'convert in.bmp -type palette BMP2:out.bmp'

work for simple examples but not for more complex operations like:

'convert +append img0.bmp img1.bmp img2.bmp -type palette BMP3:newimg.bmp'

Where imgN.bmp are all indexed bitmaps with the same colormap.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagemagick Cannot Write Indexed BMP

Post by fmw42 »

mkubilus wrote:Thanks for the response!

'convert in.bmp -type palette BMP3:out.bmp'
and
'convert in.bmp -type palette BMP2:out.bmp'

work for simple examples but not for more complex operations like:

'convert +append img0.bmp img1.bmp img2.bmp -type palette BMP3:newimg.bmp'

Where imgN.bmp are all indexed bitmaps with the same colormap.
First you need to put +append after all the input images. But more importantly, IM will likely take the colormap from the first image in the sequence unless you use -remap with a color palette that uses the colors in the color map. See http://www.imagemagick.org/Usage/quantize/#remap. Using -type palette probably shuffles the colormaps to different colors. But I am not positive of that. Try removing -type palette.

see also
http://www.imagemagick.org/Usage/formats/#bmp

where it recommends using -colors XX to specify the number of colors (<=256)
mkubilus
Posts: 4
Joined: 2012-12-10T19:29:03-07:00
Authentication code: 6789

Re: Imagemagick Cannot Write Indexed BMP

Post by mkubilus »

Moving +append to after the input images fixes that. I'm going to play around with -remap and -type palette to see what is ideal for my case.

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

Re: Imagemagick Cannot Write Indexed BMP

Post by fmw42 »

If all the colormaps are identical, those other options may not be needed.
mkubilus
Posts: 4
Joined: 2012-12-10T19:29:03-07:00
Authentication code: 6789

Re: Imagemagick Cannot Write Indexed BMP

Post by mkubilus »

That appears to be the case in my situation. Removing '-type palette' and '-remap' does not affect the output as long as I specify BMP3 as the output type. This still does appear to change the resultant colormap (Unused colors are stripped) but retains the BMP type as still being indexed. Perfectly fine for what I am using this for.
Post Reply