[File] [PATCH] of Magdir/images for OS/2 color pointer "CP" variant (*.ptr)

Jörg Jenderek joerg.jen.der.ek at gmx.net
Sat Jun 22 00:12:01 UTC 2019


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

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

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_Pointer

In Magdir/image there exist an attempt to identify such examples by
line
 #0	string		CP		PC color pointer image data

This pattern is too simple. So this line now becomes
 0	string		CP
And more additional test lines are needed to skip bad examples like
CPU-Z Reports.

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 color pointers i found low values like 1Ah 4Eh
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 hot spot for icons like 0 3 4 8 15 16 23 27 31
are stored in 2 bytes 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, but in ancient times of
OS/2 systems with less RAM dimensions are low. The typical dimension
sizes are 32. That also means in real examples hot spot
values are low (maybe maximal 256). So upper bits of short stored
value seems to be always null. So maybe skip bad examples by looking
for valid hot spot coordinates by additional test line like
 >>6	ulelong&0xFE00FE00	=0
But i do not use this test.

After the first header comes the DIB header. In the first 4 bytes the
DIB header size is stored. This can be shown by line like
 >>14	ulelong		x		\b, dib header size %u
For the considered color pointers only 2 values 12 or 64 occur. So
test also for valid dib header sizes and start displaying by line
 >14	ulelong		<65		OS/2
Now afterwards show file name extension and a user defined mime type
according to nirsoft.net extension web site by lines
 !:mime	image/x-ibm-pointer
 !:ext	ptr

Afterwards split into 2 branches parts. First considered the OS/2 1.x
variant by checking for dib header size twelve and show specific icon
dimensions by lines
 >>14	ulelong		12		1.x color icon
 >>>18	uleshort	x		%u x
 >>>20	uleshort/2	x		%u
 >>>24	uleshort	>1		x %u

For OS/2 image width and height fields are unsigned integers whereas
for Microsoft Windows variants signed integers are used. The stored
height value was always the double of the real height. So dived
value by 2 before displaying value.
Typical values for number of bits per pixel (color depth) are
32 24 16 8 4 1, but i only found value one. So show this values only
if not one.

The other branch is for the OS/2 2.x variant which start with looking
for dib header size 64 and then display specific dimension by lines
 >>14	ulelong		64		2.x color icon
 >>>18	ulelong		x		%u x
 >>>22	ulelong/2	x		%u
 >>>28	uleshort	>1		x %u
The main difference is that width and height values are stored as 4
byte values instead by 2 bytes.

After applying the above mentioned modifications by patch
file-5.37-images-ptr-CP.diff then unrecognized OS/2 color pointers
are now recognized and described like

cpuz.txt:      ISO-8859 text, with CRLF line terminators
128-256.ptr:   OS/2 2.x color pointer 128 x 128,
	hotspot 64x64, cbSize 78, bits offset 1188
256-24rle.ptr: OS/2 2.x color pointer 256 x 256,
	Huffman 1D compression,
	hotspot 128x128, cbSize 78, bits offset 164
MOVE.PTR:      OS/2 1.x color pointer 32 x 32,
	hotspot 10x21, cbSize 26, bits offset 106
os22-64.ptr:   OS/2 2.x color pointer 32 x 32,
	hotspot 16x16, cbSize 78, bits offset 164
sizens.PTR:    OS/2 1.x color pointer 32 x 32,
	hotspot 15x31, cbSize 26, bits offset 106
SIZENWSE.PTR:  OS/2 1.x color pointer 32 x 32,
	hotspot 3x27, cbSize 26, bits offset 106
WAITHOUR.PTR:  OS/2 1.x color pointer 32 x 32,
	hotspot 15x16, cbSize 26, bits offset 106


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

There still exist more OS/2 pointer and array 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+v8rHJQhrU1gUCXQ1yQgAKCRCv8rHJQhrU
1hRoAJ9Y458MaEMVNE5dzlCE/Rge/xUQQQCgoMZIVUpQhhsnO8iwK4JwcLxd+AU=
=NiMD
-----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-22 00:01:49 +0000
@@ -608,2 +608,42 @@
 #0	string		CP		PC color pointer image data
+# URL:		http://fileformats.archiveteam.org/wiki/OS/2_Pointer
+# Reference:	http://www.fileformat.info/format/os2bmp/egff.htm
+0	string		CP
+# skip CPU-Z Report by checking for valid dib header sizes 12 or 64
+>14	ulelong		<65		OS/2
+# http://extension.nirsoft.net/PTR
+!:mime	image/x-ibm-pointer
+!:ext	ptr
+>>14	ulelong		12		1.x color pointer
+# image width and height fields are unsigned integers for OS/2
+>>>18	uleshort	x		%u x
+# stored height = 2 * real height
+>>>20	uleshort/2	x		%u
+# number of bits per pixel (color depth). Typical 32 24 16 8 4 but only 1 found
+>>>24	uleshort	>1		x %u
+# color planes; must be 1
+#>>>22	uleshort	>1		\b, %u color planes
+>>14	ulelong		64		2.x color pointer
+# image width and height
+>>>18	ulelong		x		%u x
+# stored height = 2 * real height
+>>>22	ulelong/2	x		%u
+# number of bits per pixel (color depth). only 1 found
+>>>28	uleshort	>1		x %u
+#>>>26	uleshort	>1		\b, %u color planes
+# compression method: 0~no 3~Huffman 1D
+>>>30	ulelong		3		\b, Huffman 1D compression
+#>>>30	ulelong		>0		\b, %u compression
+# xHotspot, yHotspot; coordinates of the hotspot like 0 3 4 8 15 16 23 27 31
+>>6	uleshort		x	\b, hotspot %ux
+>>8	uleshort		x	\b%u
+# cbSize; size of header or maybe file in bytes like 1Ah 4Eh
+>>2	ulelong			x	\b, cbSize %u
+#>>2	ulelong			x	\b, cbSize %x
+# offBits; offset to bitmap data (pixel array) like 6Ah A4h E4h 4A4h
+>>10	ulelong			x	\b, bits offset %u
+#>>10	ulelong			x	\b, bits offset 0x%x
+#>>(10.l) ubequad		!0	\b, bits 0x%16.16llx
+# dib header size: 12~Ch~OS/2 1.x 64~40h~OS/2 2.x
+#>>14	ulelong		x		\b, dib header size %u
 # Conflicts with other entries [BABYL]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.37-images-ptr-CP.diff.sig
Type: application/octet-stream
Size: 95 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20190622/0018a3a0/attachment.obj>


More information about the File mailing list