[File] [PATCH] of Magdir/images, msdos for OS/2 graphic array (*.bmp *.ico)

Jörg Jenderek joerg.jen.der.ek at gmx.net
Mon Jun 24 00:12:40 UTC 2019


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

Hello,
some days ago i handle some OS/2  graphic array with file name
extension "ico" or "bmp". When i run file command version 5.37 many
 of these examples are only described as "data" and some are
misidentified as "Icon for MS Windows" like

BOOKOS2.ICO:     Icon for MS Windows
SPADE.BMP:       data
Util. 03.ICO:    Icon for MS Windows

So i add/change lines in Magdir/images. Some Information is found on
fileformats.archiveteam.org website. So i add comment line like
# URL: http://fileformats.archiveteam.org/wiki/BMP#OS.2F2_Bitmap_Array

In Magdir/image there exist an attempt to identify such examples by
line
 #0	string		BA		PC bitmap array data

This pattern is too simple. So this line now becomes
 0	string		BA
And more additional test lines are needed to skip bad examples.

The size of header or file in bytes is stored in variable cbSize.
This is now shown by line like
 >>2	ulelong			x	\b, cbSize %u
For inspected OS/2 array i found low values like 28h 5Ch.
This can be used as additional test by jumping 4 bytes before end of
header/file and test for accessibility by line like
 >>(2.l-4) ubelong		x	End of header is OK!
I do not use this, because accessing bytes beyond ranges is not a
official documented feature in file command.

So i skip old Emacs RMAIL starting with phrase "BABYL OPTIONS:" by
checking for low header size:
 >2	ulelong		<0x004c5942	OS/2 graphic array

The dimensions of the device for which this version is intended is
stored in variables cxDisplay, CyDisplay. If not null show this
display dimensions (640 x 480 for example means VGA) by lines
 >>10	uleshort	>0		\b, display %u
 >>>12	uleshort	>0		x %u

After the first header comes the first element of the graphic array.
The type of that element can be inspected by a debug line like
 >>14	string		x		\b, usType %2.2s
So it is visible that inspected array examples are just container
for OS/2 icon "IC", color icon "CI", color pointer "CP" or bitmap
"BM". Depending on embedded elements the files name extension is
different. For bitmaps the extension is "bmp" and "ico" for other
cases. This is expressed by lines
 >>14	string		BM	\b; 1st
 !:ext	bmp/bga
 >>14	string		CI	\b; 1st
 !:ext	ico
 >>14	string		CP	\b; 1st
 !:ext	ico
 >>14	string		IC	\b; 1st
 !:ext	ico
According to documentation also "bga" extension is possible, but i
found no example for that case. I also found no array with
white-black OS/2 pointers "PT".
For the OS/2 bitmaps, icons, pointer there exist already magic test
lines. So i use existing lines and inspect first array element by line
 >>14	indirect	x

Some OS/2 graphic array are misidentified by line in Magdir/msdos
which looks like:
 0 string/b \102\101\050\000\000\000\056...	Icon for MS Windows
With the knowledge of the documentation we can interpret the octal
values. So \102\101 as ASCII is BA for OS/2 graphic array. cbSize
value 40 is equivalent of \050\000\000\000. data offset 46 is same as
\056\000\000\000 and the remaining null means display dimension 0x0.
So what is expressed by line in Magdir/msdos is not a Windows icon,
but an OS/2 graphic array with specif values for cbSize, data offset
and display dimensions. So i remove that misidentifying lines by
file-5.37-msdos-ico.diff.

After applying the above mentioned modifications also by patch
file-5.37-images-bmp_ico.diff then unrecognized OS/2 graphic array
are now recognized and together with former patches for OS/2
graphics described like

BOOKOS2.ICO:     OS/2 graphic array, cbSize 40, data offset 46;
	1st OS/2 icon, cbSize 26, hotspot 8x8,
	bits offset 618
CDPlyr-1.ICO:    OS/2 graphic array, cbSize 92, data offset 230;
	1st OS/2 2.x color icon 32 x 32, hotspot 16x16, cbSize 78,
	bits offset 1018
Flag-Canada.ICO: OS/2 graphic array, cbSize 92, data offset 242;
	1st OS/2 2.x color icon 64 x 64, hotspot 7x52, cbSize 78,
	bits offset 1098
Folder-C.ICO:    OS/2 graphic array, cbSize 40, data offset 78;
	1st OS/2 1.x color icon 16 x 16, hotspot 8x8, cbSize 26,
	bits offset 636
LiveWire2.ICO:   OS/2 graphic array, cbSize 92;
	1st OS/2 2.x color pointer 32 x 32, hotspot 21x20, cbSize 78,
	bits offset 242
MEMSIZE.BMP:     OS/2 graphic array, cbSize 40;
	1st PC bitmap, OS/2 1.x format, 64 x 64
MIDIFil1.ICO:    OS/2 graphic array, cbSize 92, data offset 198;
	1st OS/2 2.x color icon 32 x 32, hotspot 16x16, cbSize 78,
	bits offset 958
MIDIPly1.ICO:    OS/2 graphic array, cbSize 92, data offset 218;
	1st OS/2 2.x color icon 32 x 32, hotspot 16x16, cbSize 78,
	bits offset 990
OS2SysF.ICO:     OS/2 graphic array, cbSize 92, data offset 100;
	1st OS/2 icon, cbSize 78, hotspot 8x8,
	bits offset 2470
RMAIL:           Emacs RMAIL
screwdri.ico:    OS/2 graphic array, cbSize 92,
	display 1024 x 768;
	1st OS/2 2.x color icon 40 x 40, hotspot 20x20, cbSize 78,
	bits offset 242
SndPly-1.ICO:    OS/2 graphic array, cbSize 92, data offset 210;
	1st OS/2 2.x color icon 32 x 32, hotspot 16x16, cbSize 78,
	bits offset 978
SndRec-2.ICO:    OS/2 graphic array, cbSize 92, data offset 214;
	1st OS/2 2.x color icon 32 x 32, hotspot 16x16, cbSize 78,
	bits offset 978
SPADE.BMP:       OS/2 graphic array, cbSize 92;
	1st PC bitmap, OS/2 2.x format, 58 x 0
Util. 03.ICO:    OS/2 graphic array, cbSize 40, data offset 46;
	1st OS/2 icon, cbSize 26, hotspot 8x8,
	bits offset 332
VdscPly1.ICO:    OS/2 graphic array, cbSize 92, data offset 234;
	1st OS/2 2.x color icon 32 x 32, hotspot 16x16, cbSize 78,
	bits offset 1018
VxFTP.ICO:       OS/2 graphic array, cbSize 40, data offset 840,
	display 640 x 350;
	1st OS/2 1.x color icon 40 x 40, hotspot 0x0, cbSize 26,
	bits offset 1080

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

There still exist more bitmap variants which are not recognized or
misidentified by file command. I will handle such things in a future
session.

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








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

iF0EARECAB0WIQS5/qNWKD4ASGOJGL+v8rHJQhrU1gUCXRAVZAAKCRCv8rHJQhrU
1tlJAKChUOyzk1i4nsJvEMlQOnfVbNnj8wCfRO7qf1Z9/HE7rdMBP4ERb1wuRSs=
=kG3l
-----END PGP SIGNATURE-----
-------------- next part --------------
--- file-5.37/magic/Magdir/msdos.old	2019-04-19 00:42:27 +0000
+++ file-5.37/magic/Magdir/msdos	2019-06-23 23:56:45 +0000
@@ -902,8 +902,4 @@
 0	string/b	MDIF\032\000\010\000\000\000\372\046\100\175\001\000\001\036\001\000 MS Windows special zipped file
 
-
-#ico files
-0	string/b	\102\101\050\000\000\000\056\000\000\000\000\000\000\000	Icon for MS Windows
-
 # Windows icons
 # Update: Joerg 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-24 00:02:54 +0000
@@ -609,3 +609,36 @@
 # Conflicts with other entries [BABYL]
+# URL:	http://fileformats.archiveteam.org/wiki/BMP#OS.2F2_Bitmap_Array
+# Note:	container for OS/2 icon "IC", color icon "CI", color pointer "CP" or bitmap "BM"
 #0	string		BA		PC bitmap array data
+0	string		BA
+# skip old Emacs RMAIL BABYL ./mail.news by checking for low header size
+>2	ulelong		<0x004c5942	OS/2 graphic array
+!:mime	image/x-os2-graphics
+#!:apple	????BMPf
+# cbSize; size of header like 28h 5Ch
+>>2	ulelong			x	\b, cbSize %u
+#>>2	ulelong			x	\b, cbSize 0x%x
+# offNext; offset to data like 0 48h F2h 4Eh 64h C6h D2h D6h DAh E6h EAh 348h
+>>6	ulelong			>0	\b, data offset %u
+#>>6	ulelong			>0	\b, data offset 0x%x
+#>>(6.l) ubequad		!0	\b, data 0x%16.16llx
+# dimensions of the intended device like 640 x 480 for VGA or 1024 x 768
+>>10	uleshort	>0		\b, display %u
+>>>12	uleshort	>0		x %u
+# usType of first array element
+#>>14	string		x		\b, usType %2.2s
+# 1 space char after "1st"
+# no *.bga examples found https://www.openwith.org/file-extensions/bga/1342
+>>14	string		BM	\b; 1st 
+!:ext	bmp/bga
+>>14	string		CI	\b; 1st 
+!:ext	ico
+>>14	string		CP	\b; 1st 
+!:ext	ico
+>>14	string		IC	\b; 1st 
+!:ext	ico
+# no white-black pointer found
+#>>14	string		PT	\b; 1st 
+#!:ext	
+>>14	indirect	x	
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.37-msdos-ico.diff.sig
Type: application/octet-stream
Size: 95 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20190624/cdd03396/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.37-images-bmp_ico.diff.sig
Type: application/octet-stream
Size: 95 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20190624/cdd03396/attachment-0001.obj>


More information about the File mailing list