Converting XPM to 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
tonyo
Posts: 2
Joined: 2018-02-15T16:45:17-07:00
Authentication code: 1152

Converting XPM to BMP

Post by tonyo »

OK, so I have an XPM file that is about 23x39 pixels, or about 7.3kb in size.
I want to convert this to a 64x96 pixel BMP file, using 256 colors per pixel.

So I try

magick image.xpm -resize 64x96 -colors 256 BMP2:image.bmp

The BMP file is now 18kb, and the bit depth is 24, not good.

If I use AhaView to convert to 8bpp BMP, the file goes down to approx. 7kb. much better.

I suspect that IM is turning the 8-bit palette plus 8 bits/pixel XPM file into a no-palette and three bytes/pixel BMP file.

What incantation do I use to get IM to make an 8bpp BMP file?

I need the smaller file for an embedded application (not much memory) and do not have a fancy embedded BMP reader that can decompress encoded BMP files.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting XPM to BMP

Post by fmw42 »

try

magick image.xpm -resize 64x96 +dither -colors 256 -depth 8 -type palette BMP2:image.bmp
tonyo
Posts: 2
Joined: 2018-02-15T16:45:17-07:00
Authentication code: 1152

Re: Converting XPM to BMP

Post by tonyo »

Amazing. Worked perfectly.

Take the rest of the day off. Tell them some guy on the internet said it was OK!

thanks again,

tony o.
Post Reply