[File] [PATCH] of Magdir/images for OS/2 bitmap variant (16 byte DIB header *.bmp)

Jörg Jenderek joerg.jen.der.ek at gmx.net
Thu Jun 27 19:52:46 UTC 2019

some days ago i handle some OS/2 bitmap variant with file name
extension "bmp". When i run file command version 5.37 all of these
examples are only described as "data". An example of such a case is
the graphic pal8os2v2-16.bmp of the BMP Suite.

Many popular graphic tools like GIMP, ImageMagick or XnView can open
the Microsoft icon variant, but are not able to open that OS/2 bitmap.
Surprisingly the Firefox web browser can open such bitmaps. Also the
Windows graphic tool IrfanView can handle such bitmaps.

So i add/change lines in Magdir/images. The information about this
variants is found on Wikipedia page about BMP format already
mentioned in magic file.

According to Wikipedia the DIB header use a format named
OS22XBITMAPHEADER. This format stores only the first 16 byte of the
os/2 variant with 64 bytes. The remaining 48 bytes are assumed to be
zero values. This variant is now recognized by additional lines
starting with
 >14	leshort	16 PC bitmap, OS/2 2.x format (16 byte DIB header)
Now afterwards show file name extension, apple id and mime type for
BMP bitmaps by lines
 !:mime		image/bmp
 !:apple	????BMPp
 !:ext		bmp

For OS/2 image width and height fields are unsigned integers whereas
for Microsoft Windows variants signed integers are used.
Typical values for number of bits per pixel (color depth) are
32 24 16 8 4 1, but i only found value 4 and 8. So show this values
only if not one.
 >>18	ulelong		x		\b, %u x
 >>22	ulelong		x		%u
 >>28	uleshort	>1		x %u

The variable cbSize now contains the the size of the whole file,
whereas for other OS/2 graphics it contains size of headers. So show
this value by line
 >>2	ulelong		x		\b, %u bytes

The stored x, y coordinates of the hot spot are not used in bitmap. So
these values seem to contain always 0.

After applying the above mentioned modifications by patch
file-5.37-images-bmp_os2-dib16.diff then unrecognized OS/2 bitmap
variants are now recognized and described like

pal8os2v2-16.bmp: PC bitmap, OS/2 2.x format (16 byte DIB header),
	127 x 64 x 8, 9246 bytes, bits offset 1054
TEAMcol-12.bmp:   PC bitmap, OS/2 2.x format (16 byte DIB header),
	518 x 412 x 4, 107194 bytes, bits offset 201326686

I hope my diff file can be applied in future version of file utility.

Now i have done all bitmap variants starting with 2 byte ASCII magic
like "BM", but there still exist some other variants. I will handle
such things in future session.

With best wishes
Jörg Jenderek
Jörg Jenderek

-------------- next part --------------
--- file-5.37/magic/Magdir/images.old	2019-04-19 00:42:27 +0000
+++ file-5.37/magic/Magdir/images	2019-06-27 19:45:06 +0000
@@ -579,2 +579,25 @@
 >>20	leshort		x		%d
+# OS22XBITMAPHEADER	same as OS/2 2.x, but only 16 bytes of DIB header stored
+# Note:			can be open by firefox, IrfanView at June 2019
+>14	leshort		16		PC bitmap, OS/2 2.x format (16 byte DIB header)
+!:mime	image/bmp
+!:apple	????BMPp
+!:ext	bmp
+# image width and height fields are unsigned integers for OS/2
+>>18	ulelong		x		\b, %u x
+>>22	ulelong		x		%u
+# number of bits per pixel (color depth); found 4 8 but also 1 24
+>>28	uleshort	>1		x %u
+# OS/2 BMP files contain only one color plane, so this value is always 1
+#>>26	uleshort	>1		\b, %u color planes
+# cbSize; size of file
+>>2	ulelong		x		\b, %u bytes
+#>>2	ulelong		x		\b, cbSize 0x%x
+# x, y coordinates of the hotspot are not used in bitmap
+#>>6	uleshort	>0		\b, hotspot %ux
+#>>>8	uleshort	x		\b%u
+# offBits; offset to bitmap data like 5Eh 41Eh
+>>10	ulelong			x	\b, bits offset %u
+#>>10	ulelong			x	\b, bits offset 0x%x
+#>>(10.l) ubequad		!0	\b, bits 0x%16.16llx
 >14	leshort		64		PC bitmap, OS/2 2.x format

More information about the File mailing list