[File] [PATCH] of Magdir/images for Device independent bitmap variant (*.dib)

Jörg Jenderek joerg.jen.der.ek at gmx.net
Tue Jul 2 20:05:34 UTC 2019


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hello,
some days ago i handle some bitmap variant with file name
extension "dib". When i run file command version 5.37 for these
examples are only described as "data".

According to fileformats.archiveteam.org about BMP sometimes the BMP
header starting with ASCII "BM" is missing and the stored bitmap
directly start with DIB header (Device independent bitmap). So this
format is similar to "PC bitmap, Windows 3.x format".
This can be verified by running ImageMagick version 6.8.9-8 command
`identify *.dib`.
So first magic line checks for valid DIB header size by line
 0	leshort		40
Two byte pattern are no unique enough. So look for valid number of
color planes which is always one for DIB bitmaps. So skip bad example
GAME by additional test line
 >12	uleshort	1	Device independent bitmap graphic

Now afterwards show file apple id and new mime type for BMP bitmaps by
lines
 !:mime	image/bmp
 !:apple	????BMPp
Instead "bmp" extension now "dib" is used. This is shown by line
 !:ext	dib

Show image dimension like in other cases by lines
 >>4	lelong		x		\b, %d x
 >>8	lelong		x		%d x
 >>14	leshort		x		%d

I also show compression method as numeric by line like
 >>16	ulelong		>0		\b, %u compression
I also show number of used important colors in pallette if not 0 by
 >>36	ulelong		>0		\b, %u important colors

After applying the above mentioned modifications by patch
file-5.37-images-dib.diff then DIB bitmap variants are now recognized
and described with  like

GAME:                data
input.dib:           Device independent bitmap graphic,
	70 x 46 x 24,
	image size 9752, resolution 2925 x 2925 px/m
LILTREES.DIB:        Device independent bitmap graphic,
	640 x 480 x 8, 	1 compression,
	image size 55754,
	256 important colors
money-24bit-os2.DIB: Device independent bitmap graphic,
	455 x 341 x 24,
	image size 466488
OS2LOGO3.DIB:        Device independent bitmap graphic,
	373 x 409 x 8, 1 compression,
	image size 90316, resolution 2913 x 2913 px/m,
	256 important colors

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

With best wishes
Jörg Jenderek
- --
Jörg Jenderek










-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iF0EARECAB0WIQS5/qNWKD4ASGOJGL+v8rHJQhrU1gUCXRu5AAAKCRCv8rHJQhrU
1uB7AKCEbBDRSDG/4YjZKaWAtb+qALXMAgCeJbU9tmTeGRyixDzXUlF2c6KlPw4=
=GIky
-----END PGP SIGNATURE-----
-------------- next part --------------
--- file-5.37/magic/Magdir/images.old	2019-04-19 00:42:27 +0000
+++ file-5.37/magic/Magdir/images	2019-07-02 19:25:24 +0000
@@ -574,2 +574,28 @@
 # 28bitmap_information_header.29
+# Note:	variant starting direct with DIB header see
+#	http://fileformats.archiveteam.org/wiki/BMP
+#	verified by ImageMagick version 6.8.9-8 command `identify *.dib`
+0	leshort		40
+# skip bad samples like GAME by looking for valid number of color planes
+>12	uleshort	1		Device independent bitmap graphic
+!:mime	image/bmp
+!:apple	????BMPp
+!:ext	dib
+>>4	lelong		x		\b, %d x
+>>8	lelong		x		%d x
+>>14	leshort		x		%d
+# number of color planes (must be 1) 
+#>>12	uleshort	>1		\b, %u color planes
+# compression method: 0~no 1~RLE 8-bit/pixel 3~Huffman 1D
+#>>16	ulelong		3		\b, Huffman 1D compression
+>>16	ulelong		>0		\b, %u compression
+# image size is the size of raw bitmap; a dummy 0 can be given for BI_RGB bitmaps
+>>20	ulelong		x		\b, image size %u
+# horizontal and vertical resolution of the image (pixel per metre, signed integer) 
+>>24	lelong		>0		\b, resolution %d x
+>>>28	lelong		x		%d px/m
+# number of colors in palette, or 0 to default to 2**n
+#>>32	ulelong		>0		\b, %u colors
+# number of important colors used, or 0 when every color is important
+>>36	ulelong		>0		\b, %u important colors
 0	string		BM
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.37-images-dib.diff.sig
Type: application/octet-stream
Size: 95 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20190702/0d742dec/attachment.obj>


More information about the File mailing list