jmimemagic icon indicating copy to clipboard operation
jmimemagic copied to clipboard

BMP files are not detected

Open madness-inc opened this issue 8 years ago • 3 comments

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

madness-inc avatar May 09 '17 12:05 madness-inc

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.

jpazardzievska avatar May 19 '17 09:05 jpazardzievska

Missing this in magic.xml: <match> <mimetype>image/bmp</mimetype> <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> </match>

Put it under jpeg and it will handle bmp

tbuka avatar Sep 20 '22 08:09 tbuka

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

gtsluk avatar Jun 10 '23 10:06 gtsluk