You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tika.apache.org by "Nick Burch (JIRA)" <ji...@apache.org> on 2015/06/30 16:56:05 UTC

[jira] [Commented] (TIKA-1670) Metadata.IMAGE_WIDTH and Metadata.IMAGE_LENGTH is not given for PNG files.

    [ https://issues.apache.org/jira/browse/TIKA-1670?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14608414#comment-14608414 ] 

Nick Burch commented on TIKA-1670:
----------------------------------

It's showing up for me with the Tika app:
{code}
$ java -jar tika-app-1.10-SNAPSHOT.jar --metadata festival-anak-bertanya-2015_o.png  | grep 'tiff:Image'
tiff:ImageLength: 844
tiff:ImageWidth: 600
{code}

Do you get any metadata for the file? Have you ensured that you've really got the Tika Parsers jar+dependencies available? (see http://wiki.apache.org/tika/Troubleshooting%20Tika) Does the Tika app work for you?

> 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)