[File] [PATCH] of Magdir/images for ImageMagick MIFF image
Jörg Jenderek
joerg.jen.der.ek at gmx.net
Thu Nov 21 14:41:00 UTC 2019
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
some days ago i had to handle some ImageMagick bitmaps which have
normally filename extension miff. When searching on my systems for
such files and similar test files and runnig file command version
5.37 i get unexpected output like:
AQUARIUM.MIF: data
DNA.MIF: MIFF image data
smile_anim.miff: data
TEST3-NAME.txt: data
TEST-NAME.txt: MIFF image data
Furthermore with -i option only application/octet-stream is shown and
with --extension only ??? is displayed.
First i add to Magdir/images comment with URL at ImageMagick site
about MIFF format by line:
# URL: https://imagemagick.org/script/miff.php
According to that site MIFF files should start with keyword-value
combination id=ImageMagick. So first variant examples are detected by
magic line in Magdir/images
0 string id=ImageMagick MIFF image data
A more precise identification for MIFF can be found on file formats
archive team web site. So i add this as reference by comment line:
# Reference: http://fileformats.archiveteam.org/wiki/MIFF
Furthermore there exist also examples like AQUARIUM.MIF in the
Encyclopedia of Graphic File Formats, where this phrase does not
appear at the beginning but later. Such examples usually start with
a comment that is introduced in this file format by a curly brace.
This variant is not detected by above current magic line.
For comparison reason i run other utilities.
The droid tool { found at http://droid.sourceforge.net/ } recognize
this variant described by PUID fmt/930.
The file identifier tool TrID (see http://mark0.net/soft-trid-e.html)
describes the second variant examples correctly as "ImageMagick
Machine independent File Format bitmap (with rem)" by definition
bitmap-miff-rem.trid.xml.
Third variant are for examples in which this combination appears in
a different capitalization, such as "Id=ImageMagick". Such example lik
e
smile_anim.miff can be found in the demo subdirectory of ImageMagick
source version 7.0.9-2. This variant is only recognized by newest
TrID definition bitmap-miff.trid.xml.
To catch keyword with different up-/downcase spelling and at
different offsets, first magic line now becomes:
0 search/256/bc id=imagemagick
Maybe now test condition is too relaxed. To skip bad ASCII text with
that keywords combination look for following next character. In real
MIFF images this character is space or new line. So test for that
character by second magic line
>&0 ubyte&0xD5 0 MIFF image data
Some sites on the net use mime type image/miff, but i found no such
official registered type at IANA. So i choose a user defined by line:
!:mime image/x-miff
Beside file name extension miff also mif can be found. This is now
shown by line:
!:ext miff/mif
After identifying MIFF images afterward show more information for
examples with unusual file(1) magic by line
>>0 string !id=ImageMagick starting with
Second variant starting with comment (curly brace "{") are handled by
branch with lines:
>>>0 ubyte =0x7b comment
>>>>2 string x "%s"
Third and remaining variant with letters with other case are done by
branch with lines:
>>>0 ubyte !0x7b
>>>>0 string >\0 '%-.14s'
After applying the above mentioned modifications by patch
file-5.37-images-miff.diff then i get a describing output like
AQUARIUM.MIF: MIFF image data starting with comment
" Imported from MTV raster image: aquarium.mtv"
DNA.MIF: MIFF image data
smile_anim.miff: MIFF image data starting with 'Id=ImageMagick'
TEST3-NAME.txt: data
TEST-NAME.txt: data
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+v8rHJQhrU1gUCXdah8gAKCRCv8rHJQhrU
1iJKAKDBU2nk0jy96U+/JGZ/xihhixKjAwCeNAE2k4Paq6wNM8YdCHgp876ddFI=
=X5T2
-----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-11-21 14:27:14 +0000
@@ -499,5 +499,29 @@
# Magick Image File Format
-0 string id=ImageMagick MIFF image data
+# URL: https://imagemagick.org/script/miff.php
+# Reference: http://fileformats.archiveteam.org/wiki/MIFF
+# Update: Joerg Jenderek
+# http://www.nationalarchives.gov.uk/pronom/fmt/930
+0 search/256/bc id=imagemagick
+# skip bad ASCII text by following new line~0x0A or space~0x20 character
+#>&0 ubyte x \b, next character 0x%x
+# called by TriD ImageMagick Machine independent File Format bitmap
+>&0 ubyte&0xD5 0 MIFF image data
+# https://reposcope.com/mimetype/image/miff
+#!:mime image/miff
+!:mime image/x-miff
+!:ext miff/mif
+# examples with standard file(1) magic
+#>>0 string =id=ImageMagick with standard magic
+# examples with unusual file(1) magic like
+>>0 string !id=ImageMagick starting with
+# start with comment (brace) like http://samples.fileformat.info/.../AQUARIUM.MIF
+>>>0 ubyte =0x7b comment
+# skip second character which is often a newline and show comment
+>>>>2 string x "%s"
+# does not start with comment, probably letters with other case like Id=ImageMagick
+# ImageMagick-7.0.9-2/Magick++/demo/smile_anim.miff
+>>>0 ubyte !0x7b
+>>>>0 string >\0 '%-.14s'
# Artisan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.37-images-miff.diff.sig
Type: application/octet-stream
Size: 95 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20191121/de282421/attachment.obj>
More information about the File
mailing list