[ https://issues.apache.org/jira/browse/TIKA-1670?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14608459#comment-14608459 ]
Hendy Irawan commented on TIKA-1670: ------------------------------------ All dependencies are managed by Maven, just add tika-parser and it pulls transitive dependencies. What other dependencies do I need for PNG? I don't get any metadata, and no warning or exception as well. If I change to JpegParser and read a jpg file then I get lots of metadata. In my sample project you can run directly {{mvn test}} to check > Metadata.IMAGE_WIDTH and Metadata.IMAGE_LENGTH is not given for PNG files. > -------------------------------------------------------------------------- > > Key: TIKA-1670 > URL: https://issues.apache.org/jira/browse/TIKA-1670 > Project: Tika > Issue Type: Bug > Components: parser > Affects Versions: 1.9 > Environment: Linux Mint 17.1 KDE 64bit, Oracle Java 8 > Reporter: Hendy Irawan > > Metadata.IMAGE_WIDTH and Metadata.IMAGE_LENGTH is not given for PNG files. > {noformat} > 21:40:16.057 [main] DEBUG com.hendyirawan.AppTest - Image image/png > metadata: > 21:40:16.301 [main] INFO com.hendyirawan.AppTest - ImageIO returns: > 600×844 > > java.lang.AssertionError: > Expected :600 > Actual :null > <Click to see difference> > at org.junit.Assert.fail(Assert.java:88) > at org.junit.Assert.failNotEquals(Assert.java:834) > at org.junit.Assert.assertEquals(Assert.java:118) > at org.junit.Assert.assertEquals(Assert.java:144) > at com.hendyirawan.AppTest.parsePng(AppTest.java:47) > {noformat} > Test case: https://github.com/ceefour/tika-png-bug > {code:java} > @Test > public void parsePng() throws IOException, TikaException, SAXException { > final byte[] origImage = FileUtils.readFileToByteArray(new > File("festival-anak-bertanya-2015_o.png")); > final String contentType = "image/png"; > final Metadata metadata = new Metadata(); > final Parser parser = new ImageParser(); > final ParseContext parseContext = new ParseContext(); > final DefaultHandler handler = new DefaultHandler(); > try (final ByteArrayInputStream stream = new > ByteArrayInputStream(origImage)) { > parser.parse(stream, handler, metadata, parseContext); > log.debug("Image {} metadata: {}", contentType, metadata); > stream.reset(); > final BufferedImage image = ImageIO.read(stream); > final int imageIoWidth = image.getWidth(); > final int imageIoHeight = image.getHeight(); > log.info("ImageIO returns: {}×{}", imageIoWidth, imageIoHeight); > Assert.assertEquals((Integer) imageIoWidth, > metadata.getInt(Metadata.IMAGE_WIDTH)); > Assert.assertEquals((Integer) imageIoHeight, > metadata.getInt(Metadata.IMAGE_LENGTH)); > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)