arimus / jmimemagic

jMimeMagic is a Java library for determining the MIME type of files or streams.
http://sourceforge.net/projects/jmimemagic/
Apache License 2.0
206 stars 58 forks source link

BMP files are not detected #35

Open madness-inc opened 7 years ago

madness-inc commented 7 years ago

Add the follwing test to MagicTest and it will fail:

public void testBMP() {
    System.out.print("\ntesting BMP image...");
    try {
        MagicMatch match = Magic.getMagicMatch(new File("test_docs/test.bmp"), true, false);
        if (match != null) {
            assertEquals("image/bmp", match.getMimeType());
        } else {
            System.out.print("failed");
            fail("no match in testBMP()");
        }
        System.out.print("ok");
    } catch (Exception e) {
        e.printStackTrace();
        fail("exception in testBMP(). message: " + e);
    } catch (Error e) {
        e.printStackTrace();
        fail("error in testBMP(). message: " + e.getMessage());
    }
}

I noticed there's no <match> for image/bmp in magix.xml

jpazardzievska commented 7 years ago

This was an issue in the previous version also. My implementation is based on version 0.1.4. In this version (0.1.4) I receive no mime type for bmp file type (null), whereas now in 0.1.5 the implementation is changed I get text/plain for bmp image which is wrong again.

tbuka commented 2 years ago

Missing this in magic.xml: `

image/bmp
<extension>bmp</extension>
<description>BMP image data</description>
<test offset="0" type="beshort" comparator="=">0x424d</test>
<match-list>
    <match>
        <mimetype>image/bmp</mimetype>
        <extension>bmp</extension>
        <description>JFIF standard</description>
        <test offset="6" type="string" comparator="=">JFIF</test>
    </match>
</match-list>

`

Put it under jpeg and it will handle bmp

gtsluk commented 1 year ago

The parser initializes with enclosed magic.xml only. How can I update it?