Convert file to 24bit bitmap

imagemagick

I'm using imagemagick convert to convert this image http://i.imgur.com/P1uqj9K.jpg to a bmp. However for some reason the tool I am using doesn't like the bitmap. If I save the image as a png and convert it to a 24bit bmp its fine. I tried using the following command bit it doesn't like it.

convert -verbose  -depth 8 -type truecolor infile outfile.bmp

Looking at the file I see that the 'bad' bmp has

BMÊp1 (0's) Š

The good one has

BMvp1 (0's) 6

Best Answer

I have had some trouble with BMP conversions too. I have typically specified BMP3:outfile.bmp and I normally get 24 bit BMP files. sometimes I get an 8 bit BMP when converting JPEG files. I just tried the -type truecolor (having seen it here) and now it looks like I get a 24 bit BMP in the cases where I used to get only 8 bits.

I also use these switches:

-units PixelsPerInch -density 72 -compress None -depth 24

the -depth 24 should do a 24 bit BMP (the depth -8 in your case may also be causing a problem) but as I said I sometimes get 8 bits even with the 24 specified.

the -units and -density cases corrected a problem where sometimes I would get a 0 for the biXPelsPerMeter and biYPelsPerMeter fields in the BMP header (it did not seem to cause a problem though). by the way I have not found a good explanation of these 2 fields.

the -compress None was required because sometimes a conversion generated a compressed BMP - no logical reason for doing that was found.

hopefully this will be of some help but I am not an expert on this subject - I just tried a few things and looked around using Google and came up with the above switch settings.

Related Question