@Test public void testJPEGTitleAndDescription() throws Exception { Metadata metadata = new Metadata(); metadata.set(Metadata.CONTENT_TYPE, "image/jpeg"); try (InputStream stream = getClass().getResourceAsStream("/test-documents/testJPEG_commented.jpg")) { parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); } assertEquals("Tosteberga \u00C4ngar", metadata.get(TikaCoreProperties.TITLE)); assertEquals("Bird site in north eastern Sk\u00E5ne, Sweden.\n(new line)", metadata.get(TikaCoreProperties.DESCRIPTION)); assertEquals("Some Tourist", metadata.get(TikaCoreProperties.CREATOR)); List<String> keywords = Arrays.asList(metadata.getValues(TikaCoreProperties.SUBJECT)); assertTrue(keywords.contains("coast")); assertTrue(keywords.contains("bird watching")); assertEquals("103", metadata.get(Metadata.IMAGE_WIDTH)); assertEquals("77", metadata.get(Metadata.IMAGE_LENGTH)); assertEquals("8", metadata.get(Metadata.BITS_PER_SAMPLE)); assertEquals(null, metadata.get(Metadata.SAMPLES_PER_PIXEL)); assertEquals("1.0E-6", metadata.get(Metadata.EXPOSURE_TIME)); assertEquals("2.8", metadata.get(Metadata.F_NUMBER)); assertEquals("4.6", metadata.get(Metadata.FOCAL_LENGTH)); assertEquals("114", metadata.get(Metadata.ISO_SPEED_RATINGS)); assertEquals(null, metadata.get(Metadata.EQUIPMENT_MAKE)); assertEquals(null, metadata.get(Metadata.EQUIPMENT_MODEL)); assertEquals(null, metadata.get(Metadata.SOFTWARE)); assertEquals("1", metadata.get(Metadata.ORIENTATION)); assertEquals("300.0", metadata.get(Metadata.RESOLUTION_HORIZONTAL)); assertEquals("300.0", metadata.get(Metadata.RESOLUTION_VERTICAL)); assertEquals("Inch", metadata.get(Metadata.RESOLUTION_UNIT)); assertEquals("IEC", metadata.get("ICC:Device manufacturer").trim()); assertNull(metadata.get("Device manufacturer")); }
public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { TemporaryResources tmp = new TemporaryResources(); try { TikaInputStream tis = TikaInputStream.get(stream, tmp); new ImageMetadataExtractor(metadata).parseJpeg(tis.getFile()); new JempboxExtractor(metadata).parse(tis); } finally { tmp.dispose(); } XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); xhtml.endDocument(); }
JpegParser extends AbstractParser { public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { TemporaryResources tmp = new TemporaryResources(); try { TikaInputStream tis = TikaInputStream.get(stream, tmp); new ImageMetadataExtractor(metadata).parseJpeg(tis.getFile()); new JempboxExtractor(metadata).parse(tis); } finally { tmp.dispose(); } XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); xhtml.endDocument(); } }
JpegParser extends AbstractParser { public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { TemporaryResources tmp = new TemporaryResources(); try { TikaInputStream tis = TikaInputStream.get(stream, tmp); new ImageMetadataExtractor(metadata).parseJpeg(tis.getFile()); new JempboxExtractor(metadata).parse(tis); } finally { tmp.dispose(); } XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); xhtml.endDocument(); }  }
JpegParser extends AbstractParser { public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { TemporaryResources tmp = new TemporaryResources(); try { TikaInputStream tis = TikaInputStream.get(stream, tmp); new ImageMetadataExtractor(metadata).parseJpeg(tis.getFile()); new JempboxExtractor(metadata).parse(tis); } finally { tmp.dispose(); } XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); xhtml.endDocument(); }  Set<MediaType> getSupportedTypes(ParseContext context); void parse(
            InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context); }
JpegParser extends AbstractParser { public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { TemporaryResources tmp = new TemporaryResources(); try { TikaInputStream tis = TikaInputStream.get(stream, tmp); new ImageMetadataExtractor(metadata).parseJpeg(tis.getFile()); new JempboxExtractor(metadata).parse(tis); } finally { tmp.dispose(); } XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); xhtml.endDocument(); }  Set<MediaType> getSupportedTypes(ParseContext context); void parse(
            InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context);  }