diff --git a/README.md b/README.md index 69d8f7e..9908ad0 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ assert_eq!(kind.extension(), "foo"); - **jxr** - `image/vnd.ms-photo` - **psd** - `image/vnd.adobe.photoshop` - **ico** - `image/vnd.microsoft.icon` +- **ora** - `image/openraster` #### Video diff --git a/src/map.rs b/src/map.rs index 1d92627..dbe82f4 100644 --- a/src/map.rs +++ b/src/map.rs @@ -203,6 +203,12 @@ matcher_map!( "jxl", matchers::image::is_jxl ), + ( + MatcherType::Image, + "image/openraster", + "ora", + matchers::image::is_ora + ), // Video ( MatcherType::Video, diff --git a/src/matchers/image.rs b/src/matchers/image.rs index 02a27ad..0ecf624 100644 --- a/src/matchers/image.rs +++ b/src/matchers/image.rs @@ -162,6 +162,38 @@ fn is_isobmff(buf: &[u8]) -> bool { buf.len() >= ftyp_length } +pub fn is_ora(buf: &[u8]) -> bool { + buf.len() > 57 + && buf[0] == 0x50 + && buf[1] == 0x4B + && buf[2] == 0x3 + && buf[3] == 0x4 + && buf[30] == 0x6D + && buf[31] == 0x69 + && buf[32] == 0x6D + && buf[33] == 0x65 + && buf[34] == 0x74 + && buf[35] == 0x79 + && buf[36] == 0x70 + && buf[37] == 0x65 + && buf[38] == 0x69 + && buf[39] == 0x6D + && buf[40] == 0x61 + && buf[41] == 0x67 + && buf[42] == 0x65 + && buf[43] == 0x2F + && buf[44] == 0x6F + && buf[45] == 0x70 + && buf[46] == 0x65 + && buf[47] == 0x6E + && buf[48] == 0x72 + && buf[49] == 0x61 + && buf[50] == 0x73 + && buf[51] == 0x74 + && buf[52] == 0x65 + && buf[53] == 0x72 +} + // GetFtyp returns the major brand, minor version and compatible brands of the ISO-BMFF data fn get_ftyp(buf: &[u8]) -> Option<(&[u8], &[u8], impl Iterator)> { if buf.len() < 16 { diff --git a/testdata/sample.ora b/testdata/sample.ora new file mode 100644 index 0000000..b4d4906 Binary files /dev/null and b/testdata/sample.ora differ diff --git a/tests/image.rs b/tests/image.rs index 6e68be7..ecaf351 100644 --- a/tests/image.rs +++ b/tests/image.rs @@ -27,3 +27,5 @@ test_format!(Image, "image/heif", "heif", heif, "sample.heic"); test_format!(Image, "image/avif", "avif", avif, "sample.avif"); test_format!(Image, "image/jxl", "jxl", jxl, "spline_on_first_frame.jxl"); + +test_format!(Image, "image/openraster", "ora", ora, "sample.ora");