0 Replies Latest reply: Jul 4, 2011 11:24 PM by 873207 RSS

    Splitting TIFF Image using JAI API and saving using ImageIO: ERROR

    873207
      Hi,

      I'm facing below exception and tried to find out solution but didn't get much from google.

      <B>Exception while spliting images into pages and writing it to file</B>

      Caused by: java.lang.Error: Invalid code encountered while decoding 2D group 4 compressed data.
      at com.sun.media.jai.codecimpl.TIFFFaxDecoder.decodeT6(TIFFFaxDecoder.java:1027)
      at com.sun.media.jai.codecimpl.TIFFImage.getTile(TIFFImage.java:1067)
      at com.sun.media.jai.codecimpl.SimpleRenderedImage.getData(SimpleRenderedImage.java:462)
      at com.sun.media.jai.codecimpl.SimpleRenderedImage.getData(SimpleRenderedImage.java:422)
      at com.sun.media.jai.codec.ImageDecoderImpl.decodeAsRaster(ImageDecoderImpl.java:138)

      Code:fileData is byte data.

      ByteArraySeekableStream ss = new ByteArraySeekableStream(fileData)
      ImageDecoder dec = ImageCodec.createImageDecoder("tiff", ss, null);
      int count = dec.getNumPages();
      TIFFEncodeParam param = new TIFFEncodeParam();
      param.setCompression(TIFFEncodeParam.COMPRESSION_GROUP4);
      param.setLittleEndian(false);
      +<b>RenderedImage page = dec.decodeAsRenderedImage(pageNumber);</b>+
      File file = new File("c://image1.tiff");
      +<b>ImageIO.write(page,"tiff",file); // Here on this line it is throwing exception</b>+


      <B>
      Is there any incompatibility with the file compression type for ImageIO API and JAI API?
      Can it be the problem with the jars?
      </B>


      Jars:

      jai-core-1.1.3.jar
      jai-codec-1.1.3.jar
      jai-imageio-1.1.jar
      java 6

      It would be helpful if some one has any idea, please share.

      Thanks.

      Edited by: 870204 on Jul 4, 2011 9:24 PM