[solved] from PNG til 1bpp BMP in one step ?

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
myicq
Posts: 29
Joined: 2012-04-11T04:23:21-07:00
Authentication code: 8675308

[solved] from PNG til 1bpp BMP in one step ?

Post by myicq »

I need to create a 1bpp BMP image, plain and simple.

My source for test is a PNG as exported by InkScape.

I think I tried every single combination of -type bilevel, -depth 2 etc etc - but always I get returned a 24 bpp image.

I have put sample files here: http://ge.tt/5Ob8ZOK/v/0

What I need is to go from drawing.png to drawing.bmp, but have the result be like drawing2.bmp

A diff with identify:
drawing.txt: Depth:8/1-bit 0..255 color 2.348 MB
drawing2.txt Depth: 1-bit 0..1 color 98 KB

it works if I do an additional
convert -threshold 2 drawing.bmp drawing2.bmp

but it's an extra step.

I use WinXP ImageMagick 6.7.6-5 Q16

Feel free to use my sample files to test.

Thanks !
Last edited by myicq on 2012-07-13T00:28:26-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: from PNG til 1bpp BMP in one step ?

Post by fmw42 »

You need to look more closely at the verbose info. Your file has an alpha channel. Turn it off.

convert drawing.png -alpha off drawing.bmp

If that does not work, then try using BMP3:drawing.bmp or BMP2:drawing.bmp

convert drawing.png -alpha off -depth 1 -type bilevel BMP3:drawing.bmp

But I get the same result as the first.

As far as I know the result will always be palette, 8/1 bit. I do not know if IM supports a bilevel BMP.

however, see
http://www.imagemagick.org/Usage/formats/#bmp and the part about using ppm and pnmdepth
myicq
Posts: 29
Joined: 2012-04-11T04:23:21-07:00
Authentication code: 8675308

[solved] Re: from PNG til 1bpp BMP in one step ?

Post by myicq »

Code: Select all

c:\im\convert drawing.png -type bilevel -colors 256 drawing.bmp
This did the trick. The -colors 256 is from the section on BMP linked to here.

Thanks for all help :)
Post Reply