[File] [PATCH] of Magdir/images for "IC" icon variant (*.ico)

Jörg Jenderek joerg.jen.der.ek at gmx.net
Sun Jun 16 01:53:32 UTC 2019


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

Hello,
some days ago i handle some OS/2 icon files with file name extension
"ico". When i run file command version 5.37 all of these examples
are only described as "data".

More irritating is the fact that ico extension is used for MS
Windows icons. Many popular graphic tools like GIMP, ImageMagick or
XnView can open the Microsoft icon variant, but are not able to open
that OS/2 icon variant. Finally i find a command line converter tool
"deark" which is able to handle such icons by module os2bmp. So
information about inspected icon is shown by list and debug option
like in example command line:
	deark -l -d3 OS2MEMU.ICO

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/OS/2_Icon
The file format of such icons is described in the OS/2 Presentation
Manager Programming Reference Guide, Vol III stored for example as
PM.TXT on web site site http://www.fileformat.info .

In Magdir/image there exist an attempt to identify such examples by
line
 #0	string		IC		PC icon data

Unfortunately this is too simple, because these pattern is also
matched by Lotus smart icons *.smi. So this line now becomes
 0	string			IC
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 icons i found low values like like 1ah 120h 420h.
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.

The coordinates of the hotspot for icons like 16 or 32 is stored in
variables xHotspot and yHotspot which are now shown by lines like
 >>6	uleshort		x	\b, hotspot %ux
 >>8	uleshort		x	\b%u
Nowadays icon can becomes big with dimensions like 256x256, but in
ancient times of OS/2 systems with less RAM dimensions are low. The
documentation mention icon dimension 16x16, 20x20, 32x32, and 40x40.
That also means hot spot values are low (maybe maximal 40). So upper
byte of short stored value seems to be always null. So skip bad
examples like *.smi by looking for valid hot spot coordinates by
additional test line like
 >6	ulelong&0xFF00FF00	=0	OS/2 icon
Now afterwards show file name extension and a user defined mime type
by lines
 !:mime	image/x-os2-ico
 !:ext	ico

After applying the above mentioned modifications by patch
file-5.37-images-ico-IC.diff then unrecognized OS/2 icons are now
described like

LANMANGR.ICO: OS/2 icon, cbSize 288, hotspot 16x16, bits offset 32
OS2MEMU.ICO:  OS/2 icon, cbSize 26, hotspot 32x32, bits offset 32
WP50.ICO:     OS/2 icon, cbSize 1056, hotspot 32x32, bits offset 32

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

There exist more OS/2 icons and bitmap files which are not
recognized or misidentified by file command. I will handles such
things in 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+v8rHJQhrU1gUCXQWhEwAKCRCv8rHJQhrU
1ryZAJwIVtstijKZ8FCm6GL6wRi6ZBX4mwCgqbbikyCLaVbL+2vgMLW049KNxiM=
=DSzU
-----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-06-15 23:14:41 +0000
@@ -603,4 +603,22 @@
 >>28	leshort		x		%d
-# Too simple - MPi
-#0	string		IC		PC icon data
+# Update:	Joerg Jenderek
+# URL:		http://fileformats.archiveteam.org/wiki/OS/2_Icon
+# Reference:	http://www.fileformat.info
+#		/format/os2bmp/spec/902d5c253f2a43ada39c2b81034f27fd/view.htm
+# Note: verified by command like `deark -l -d3 OS2MEMU.ICO`
+0	string			IC
+# skip Lotus smart icon *.smi by looking for valid hotspot coordinates
+>6	ulelong&0xFF00FF00	=0	OS/2 icon
+# jump 4 bytes before end of header/file and test for accessibility
+#>>(2.l-4) ubelong		x	End of header is OK!
+!:mime	image/x-os2-ico
+!:ext	ico
+# cbSize; size of header or file in bytes like 1ah 120h 420h
+>>2	ulelong			x	\b, cbSize %u
+# xHotspot, yHotspot; coordinates of the hotspot for icons like 16 32
+>>6	uleshort		x	\b, hotspot %ux
+>>8	uleshort		x	\b%u
+# offBits; offset in bytes to the beginning of the bit-map pel data like 20h
+>>10	ulelong			x	\b, bits offset %u
+#>>(10.l) ubequad		x	\b, bits 0x%16.16llx
 #0	string		PI		PC pointer image data
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.37-database-ico-IC.diff.sig
Type: application/octet-stream
Size: 95 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20190616/23192d3b/attachment.obj>


More information about the File mailing list