Skip to content

Commit 201ba73

Browse files
committed
Merge branch 'main' into metafile-rendering
# Conflicts: # CHANGES.txt
2 parents 6b14289 + 0baf52f commit 201ba73

9 files changed

Lines changed: 970 additions & 7 deletions

File tree

CHANGES.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ Release 4.1.0 - unreleased
1111
OLE2 formats (a WMF) as a THUMBNAIL embedded document, as the OOXML
1212
parsers do with the docProps thumbnail (TIKA-4855).
1313

14+
* Raw camera formats are detected by content: RawTiffDetector tells
15+
Nikon NEF/NRW, Pentax PEF/PTX, Sony ARW/SRF/SR2, Samsung SRW and Adobe
16+
DNG from a plain TIFF by their image directory (DNGVersion, the vendor
17+
Compression codes, or a CFA/LinearRaw image plus Make), and Fuji RAF,
18+
Panasonic RW2, Minolta MRW and the remaining Olympus ORF byte orders
19+
get magic entries. Streams without a file name used to be image/tiff.
20+
image/x-raw-samsung (*.srw) is new and parsed by RawTiffParser
21+
(TIKA-4861).
22+
1423
* DWGReadParser emits the drawing's THUMBNAILIMAGE as a THUMBNAIL embedded
1524
document instead of INLINE (TIKA-4853).
1625

tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7189,6 +7189,9 @@
71897189

71907190
<mime-type type="image/x-raw-fuji">
71917191
<_comment>Fuji raw image</_comment>
7192+
<magic priority="50">
7193+
<match value="FUJIFILMCCD-RAW" type="string" offset="0"/>
7194+
</magic>
71927195
<glob pattern="*.raf"/>
71937196
</mime-type>
71947197

@@ -7243,6 +7246,9 @@
72437246

72447247
<mime-type type="image/x-raw-minolta">
72457248
<_comment>Minolta raw image</_comment>
7249+
<magic priority="50">
7250+
<match value="\x00MRM" type="string" offset="0"/>
7251+
</magic>
72467252
<glob pattern="*.mrw"/>
72477253
</mime-type>
72487254

@@ -7255,8 +7261,11 @@
72557261

72567262
<mime-type type="image/x-raw-olympus">
72577263
<_comment>Olympus raw image</_comment>
7264+
<!-- IIRO and IIRS little endian, MMOR big endian -->
72587265
<magic priority="50">
72597266
<match offset="0" type="string" value="\x49\x49\x52\x4F"/>
7267+
<match offset="0" type="string" value="\x49\x49\x52\x53"/>
7268+
<match offset="0" type="string" value="\x4D\x4D\x4F\x52"/>
72607269
</magic>
72617270
<glob pattern="*.orf"/>
72627271
</mime-type>
@@ -7268,6 +7277,12 @@
72687277
<glob pattern="*.pef"/>
72697278
</mime-type>
72707279

7280+
<mime-type type="image/x-raw-samsung">
7281+
<_comment>Samsung raw image</_comment>
7282+
<sub-class-of type="image/tiff" />
7283+
<glob pattern="*.srw"/>
7284+
</mime-type>
7285+
72717286
<mime-type type="image/x-raw-sony">
72727287
<_comment>Sony raw image</_comment>
72737288
<sub-class-of type="image/tiff" />
@@ -7298,6 +7313,10 @@
72987313

72997314
<mime-type type="image/x-raw-panasonic">
73007315
<_comment>Panasonic raw image</_comment>
7316+
<!-- RW2: a TIFF-like header with its own magic number 0x55 -->
7317+
<magic priority="50">
7318+
<match value="IIU\x00" type="string" offset="0"/>
7319+
</magic>
73017320
<glob pattern="*.raw"/>
73027321
<glob pattern="*.rw2"/>
73037322
</mime-type>

tika-parsers/tika-parsers-standard/tika-parsers-standard-integration-tests/src/test/java/org/apache/tika/detect/TestContainerAwareDetector.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,22 @@ private void assertTypeByNameAndData(String dataFile, String name, String typeFr
123123
}
124124
}
125125

126+
/**
127+
* TIFF-based raw camera formats, told apart by RawTiffDetector without a
128+
* file name (TIKA-4861); a plain TIFF and a CR2 (fixed signature) are
129+
* untouched.
130+
*/
131+
@Test
132+
public void testRawCameraFormatsByData() throws Exception {
133+
assertTypeByData("testNEF.nef", "image/x-raw-nikon");
134+
assertTypeByData("testARW.arw", "image/x-raw-sony");
135+
assertTypeByData("testPEF.pef", "image/x-raw-pentax");
136+
assertTypeByData("testDNG.dng", "image/x-raw-adobe");
137+
assertTypeByData("testDNG_bigtiff.dng", "image/x-raw-adobe");
138+
assertTypeByData("testCR2.cr2", "image/x-canon-cr2");
139+
assertTypeByData("testTIFF.tif", "image/tiff");
140+
}
141+
126142
@Test
127143
public void testDetectOLE2() throws Exception {
128144
/* // Microsoft office types known by POI

tika-parsers/tika-parsers-standard/tika-parsers-standard-integration-tests/src/test/java/org/apache/tika/detect/TestDetectorLoading.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,19 @@ public void testBasic() throws Exception {
3232
//integration test - detectors should be sorted alphabetically by class name
3333
Detector detector = TikaLoader.loadDefault().loadDetectors();
3434
List<Detector> detectors = ((CompositeDetector) detector).getDetectors();
35-
assertEquals(7, detectors.size());
35+
assertEquals(8, detectors.size());
3636
// Sorted alphabetically by full class name (all are org.apache.tika.*)
3737
assertEquals("org.apache.tika.detect.apple.BPListDetector", detectors.get(0).getClass().getName());
3838
assertEquals("org.apache.tika.detect.gzip.GZipSpecializationDetector",
3939
detectors.get(1).getClass().getName());
40-
assertEquals("org.apache.tika.detect.microsoft.POIFSContainerDetector",
40+
assertEquals("org.apache.tika.detect.image.RawTiffDetector",
4141
detectors.get(2).getClass().getName());
42-
assertEquals("org.apache.tika.detect.mkv.MatroskaDetector", detectors.get(3).getClass().getName());
43-
assertEquals("org.apache.tika.detect.ogg.OggDetector", detectors.get(4).getClass().getName());
44-
assertEquals("org.apache.tika.detect.ole.MiscOLEDetector", detectors.get(5).getClass().getName());
42+
assertEquals("org.apache.tika.detect.microsoft.POIFSContainerDetector",
43+
detectors.get(3).getClass().getName());
44+
assertEquals("org.apache.tika.detect.mkv.MatroskaDetector", detectors.get(4).getClass().getName());
45+
assertEquals("org.apache.tika.detect.ogg.OggDetector", detectors.get(5).getClass().getName());
46+
assertEquals("org.apache.tika.detect.ole.MiscOLEDetector", detectors.get(6).getClass().getName());
4547
assertEquals("org.apache.tika.detect.zip.DefaultZipContainerDetector",
46-
detectors.get(6).getClass().getName());
48+
detectors.get(7).getClass().getName());
4749
}
4850
}

tika-parsers/tika-parsers-standard/tika-parsers-standard-integration-tests/src/test/java/org/apache/tika/mime/TestMimeTypes.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package org.apache.tika.mime;
1818

19+
import static java.nio.charset.StandardCharsets.US_ASCII;
1920
import static java.nio.charset.StandardCharsets.UTF_16BE;
2021
import static java.nio.charset.StandardCharsets.UTF_16LE;
2122
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -894,7 +895,17 @@ public void testRawDetection() throws Exception {
894895
assertTypeByName("image/x-raw-minolta", "x.mrw");
895896
assertTypeByName("image/x-raw-nikon", "x.nef");
896897
assertTypeByName("image/x-raw-nikon", "x.nrw");
898+
assertTypeByName("image/x-raw-samsung", "x.srw");
899+
//MimeTypes alone sees a TIFF; RawTiffDetector tells the raw formats apart,
900+
//see TestContainerAwareDetector
897901
assertTypeByData("image/tiff", "testNEF.nef");
902+
//formats with a fixed signature (TIKA-4861)
903+
assertTypeByData("image/x-raw-fuji", "FUJIFILMCCD-RAW 0201FF393103".getBytes(US_ASCII));
904+
assertTypeByData("image/x-raw-panasonic", new byte[]{'I', 'I', 'U', 0, 0x18, 0, 0, 0});
905+
assertTypeByData("image/x-raw-minolta", new byte[]{0, 'M', 'R', 'M', 0, 0, 0, 0});
906+
assertTypeByData("image/x-raw-olympus", new byte[]{'I', 'I', 'R', 'O', 8, 0, 0, 0});
907+
assertTypeByData("image/x-raw-olympus", new byte[]{'I', 'I', 'R', 'S', 8, 0, 0, 0});
908+
assertTypeByData("image/x-raw-olympus", new byte[]{'M', 'M', 'O', 'R', 0, 0, 0, 8});
898909
assertTypeByNameAndData("image/x-raw-nikon", "testNEF.nef");
899910
assertTypeByData("image/tiff", "testARW.arw");
900911
assertTypeByNameAndData("image/x-raw-sony", "testARW.arw");

0 commit comments

Comments
 (0)