[File] [PATCH] of msdos magic for MS Windows ICOns (missing space char, mime type)

Jörg Jenderek joerg.jen.der.ek at gmx.net
Sat Nov 10 22:34:16 UTC 2018


Hello,

on 11.06.2016 i send a patch for file command version 5.27 to do a
better recognition of MS Windows ICOns and CURsors.

Now i run the new file command version 5.34 with -k option on some
Windows icons, cutting off last data i get a strange looking output like:

260-16.ico:          MS Windows icon resource - 260 icons, 16x16,
	16 colors
	, 4 bits/pixel, 16x16, 16 colors, 4 bits/pixel
	(Lepton 2.x), scale 4609-4354, spot sensor temperature 0.000000
	, color scheme 2, minimum point enabled, maximum point enabled
	, calibration: offset 0.000000, slope 0.000000
help-icon16-png.ico: MS Windows icon resource - 17 icons, 256x256,
	16 colors
	withPNG image data, 256 x 256, 8-bit/color RGBA, non-interlaced
	, 4 bits/pixel, 48x48, 16 colors, 4 bits/pixel

After comparing with expected output, there are 2 errors.

The first is only a cosmetic one. The phrase "withPNG image data" should
look like "with PNG image data". MS Windows icon are just container for
some PNG or DIB images. The offset to embedded image is stored at
position 12. By pointer expression embedded image can be inspected. When
it start with magic string \x89PNG, it is a PNG image and not a DIB
image. This was done by line:
 >(12.l)		ubelong		=0x89504e47

Afterward the embedded PNG image can be inspected. The easiest way is to
use the already identifying lines starting with "PNG image data" in
Magdir/images. This should look like
 >>&-4		indirect	x	\b with
This line must contain 1 trailing space character to get correct phrase
"with PNG image data".

I am quit sure that this 1 space character error occur also for some
other file formats with similar expressions.

In past times most distributions use user defined mime type
"image/x-icon". But nowadays most distribution seems to use the official
IANA mime type found at
https://www.iana.org/assignments/media-types/image/vnd.microsoft.icon
So i also changed extension line to:
 !:mime		image/vnd.microsoft.icon

After applying the above mentioned modifications by patch
file-5.35-msdos-ico.diff then all Windows icons are described without 1
space character bug.

The second error is misidentifying many Windows icons as "(Lepton 2.x)"
or "(Lepton 3.x)". This misidentification does not occur in version
5.32. These massages are triggered by Magdir/measure. So in that file
the magic lines for DIY-Thermocam data seems to be not accurate enough.
So somebody should check that file.

The MS DOS operating system has never been a system with a graphical
interface. Therefore all magic lines concerning graphic stuff inside
Magdir/msdos should be moved to other files. Microsoft use ICO files for
their Windows operating system. But nowadays many graphic software and
also browser with favi icon support can handle MS Windows ICOns. So such
magic lines shout not be moved to Magdir/windows. The best place in my
opinion would be Magdir/images.

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

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

-------------- next part --------------
--- file-5.35/magic/Magdir/msdos.old	2018-07-25 07:05:34 +0000
+++ file-5.35/magic/Magdir/msdos	2018-11-10 19:33:55 +0000
@@ -926,4 +926,5 @@
 >>>0		ubelong		0x00000100	icon resource
-#!:mime		image/vnd.microsoft.icon
-!:mime		image/x-icon
+# https://www.iana.org/assignments/media-types/image/vnd.microsoft.icon
+!:mime		image/vnd.microsoft.icon
+#!:mime		image/x-icon
 !:ext		ico
@@ -973,3 +974,4 @@
 >(12.l)		ubelong		=0x89504e47
->>&-4		indirect	x	\b with
+# 1 space char after "with" to get phrase "with PNG image" by magic in ./images
+>>&-4		indirect	x	\b with 
 # DIB image


More information about the File mailing list