You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2020/09/08 15:29:08 UTC

[tika] branch main updated: TIKA-3193 -- add mime detection for avif

This is an automated email from the ASF dual-hosted git repository.

tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/main by this push:
     new a02ee98  TIKA-3193 -- add mime detection for avif
a02ee98 is described below

commit a02ee9821339441c2fde40ea483e850d99ad0ba1
Author: tallison <ta...@apache.org>
AuthorDate: Tue Sep 8 11:28:46 2020 -0400

    TIKA-3193 -- add mime detection for avif
---
 .../resources/org/apache/tika/mime/tika-mimetypes.xml     |  12 +++++++++++-
 .../src/test/resources/test-documents/testAVIF.avif       | Bin 0 -> 185 bytes
 .../src/test/java/org/apache/tika/mime/TestMimeTypes.java |   8 ++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml b/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml
index 1b11023..cfa3803 100644
--- a/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml
+++ b/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml
@@ -5483,7 +5483,17 @@
     </magic>
     <glob pattern="*.gif"/>
   </mime-type>
-
+  <mime-type type="image/avif">
+    <!-- According to https://github.com/libvips/libvips/pull/1657
+      older avif used to use the the heif 'ftypmif1' as well -->
+    <_comment>AV1 Image File</_comment>
+    <acronym>AVIF</acronym>
+    <tika:link>https://en.wikipedia.org/wiki/AV1#AV1_Image_File_Format_(AVIF)</tika:link>
+    <magic priority="60">
+      <match value="ftypavif" type="string" offset="4"/>
+    </magic>
+    <glob pattern="*.avif"/>
+  </mime-type>
   <mime-type type="image/heif">
     <_comment>HEIF - High Efficiency Image File</_comment>
     <acronym>HEIF</acronym>
diff --git a/tika-parser-modules/tika-parser-image-module/src/test/resources/test-documents/testAVIF.avif b/tika-parser-modules/tika-parser-image-module/src/test/resources/test-documents/testAVIF.avif
new file mode 100644
index 0000000..359474c
Binary files /dev/null and b/tika-parser-modules/tika-parser-image-module/src/test/resources/test-documents/testAVIF.avif differ
diff --git a/tika-parser-modules/tika-parser-integration-tests/src/test/java/org/apache/tika/mime/TestMimeTypes.java b/tika-parser-modules/tika-parser-integration-tests/src/test/java/org/apache/tika/mime/TestMimeTypes.java
index de6f9b2..c507986 100644
--- a/tika-parser-modules/tika-parser-integration-tests/src/test/java/org/apache/tika/mime/TestMimeTypes.java
+++ b/tika-parser-modules/tika-parser-integration-tests/src/test/java/org/apache/tika/mime/TestMimeTypes.java
@@ -439,6 +439,14 @@ public class TestMimeTypes {
     }
 
     @Test
+    public void testAVIFDetection() throws Exception {
+        // The test file is an avif header fragment only, not a complete image.
+        assertType("image/avif", "testAVIF.avif");
+        assertTypeByData("image/avif", "testAVIF.avif");
+        assertTypeByName("image/avif", "testAVIF.avif");
+    }
+
+    @Test
     public void testJpegDetection() throws Exception {
         assertType("image/jpeg", "testJPEG.jpg");
         assertTypeByData("image/jpeg", "testJPEG.jpg");