I can't create a BMP4 even using bmp:format=bmp4

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?".
Locked
dreenot
Posts: 1
Joined: 2020-01-10T17:24:22-07:00
Authentication code: 1152

I can't create a BMP4 even using bmp:format=bmp4

Post by dreenot »

Hello.
I need to convert a PNG to BMP Windows V4 Bitfields.

I tried to use

convert in.png -define bmp:format=bmp4 out.bmp

But it makes a Windows V5 file, not v4.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: I can't create a BMP4 even using bmp:format=bmp4

Post by fmw42 »

In ImageMagick the default is BMP4. But it is not specified as BMP4. It is just BMP. Or you can preface the output with BMP:out.bmp.

See https://imagemagick.org/Usage/formats/#bmp

246246
Posts: 200
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: I can't create a BMP4 even using bmp:format=bmp4

Post by 246246 »

It might have been true when that document was written, but as far as I see, current default is bmp5, and there is no way to write bmp4.

$ magick logo: logo.bmp
$ file logo.bmp
logo.bmp: PC bitmap, Windows 98/2000 and newer format, 640 x 480 x 8

If the file were bmp4, file command return 'Windows 95/NT4 and newer format'.

BMP4 sample file is available from http://entropymine.com/jason/bmpsuite/

$ file bmpsuite-2.5/g/pal8v4.bmp
bmpsuite-2.5/g/pal8v4.bmp: PC bitmap, Windows 95/NT4 and newer format, 127 x 64 x 8
$ file bmpsuite-2.5/g/pal8v5.bmp
bmpsuite-2.5/g/pal8v5.bmp: PC bitmap, Windows 98/2000 and newer format, 127 x 64 x 8

Or check binary header size like this:

$ dd if=bmpsuite-2.5/g/pal8v4.bmp skip=14 bs=1 2>/dev/null | od -x | head -1 | perl -lne 'print hex((split)[1])'
108
$ dd if=bmpsuite-2.5/g/pal8v5.bmp skip=14 bs=1 2>/dev/null | od -x | head -1 | perl -lne 'print hex((split)[1])'
124

See https://en.wikipedia.org/wiki/BMP_file_ ... on_header)

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: I can't create a BMP4 even using bmp:format=bmp4

Post by fmw42 »

I will leave this to the IM developers. Perhaps you are correct. I did not know there was a bmp5.

Did you try

Code: Select all

convert image.png BMP4:image.bmp

User avatar
dlemstra
Posts: 1625
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: I can't create a BMP4 even using bmp:format=bmp4

Post by dlemstra »

The file is written as BMP5 because the image has an rendering intent. To prevent that from happening you will need to add `-intent undefined` after you read the file.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

Locked