Skip to main content

[JAI-IMAGEIO] Catch 22

4 replies [Last post]
Anonymous

I am encountering a couple bugs which have workarounds (on 1.1 beta),
but the workarounds are conflicting:

Issue 72: Error 6 when using java only to read certain CCITT Group 3 fax
tiffs
https://jai-imageio-core.dev.java.net/issues/show_bug.cgi?id=72

*Workaround*: Include native libs and the tiff reads fine

Bug from my "JVM Crash on tiff read!!!" thread
*Workaround*: Remove native libs that cause the JVM crash, and the java
code reads it fine

So because issue 72 is less severe, I am going to work around that
workaround - and am thinking of removing the native libs and catching
the IIOException Error 6 and using the old
ImageCodec.createImageEncoder(...) to do my image conversion with JAI
only (hopefully that will work!). If anyone thinks there is a better way
to go about fixing this it would be much appreciated!

Thanks much,

--
Aaron Bruegl

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Aaron Bruegl

For those interested:

I am going to not use the native libs, and I catch the Error 6 Exception
and use the old codecs to read the tiff instead and write it like so:

.. // In exception handler after ImageIO failed to read tiff
because of 'Error 6'
// Encode images to byte[]
for (RenderedImage : images) {
TIFFDirectory tiffDirectory = (TIFFDirectory)
image.getProperty("tiff_directory");
TIFFEncodeParam enParam = new TIFFEncodeParam();
enParam.setCompression(TIFFEncodeParam.COMPRESSION_GROUP4);
enParam.setExtraFields(tiffDirectory.getFields());
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ImageEncoder encoder = ImageCodec.createImageEncoder("tiff",
bout, enParam);
encoder.encode(image);
imagesBytes.add(bout.toByteArray());
}

This leads to overall ugliness of code and makes it more complicated
when different image formats are used, but hey, I guess it is working.
Though I can't wait to delete this when these bugs are fixed :)

Aaron Bruegl wrote:
> I am encountering a couple bugs which have workarounds (on 1.1 beta),
> but the workarounds are conflicting:
>
> Issue 72: Error 6 when using java only to read certain CCITT Group 3
> fax tiffs
> https://jai-imageio-core.dev.java.net/issues/show_bug.cgi?id=72
>
> *Workaround*: Include native libs and the tiff reads fine
>
> Bug from my "JVM Crash on tiff read!!!" thread
> *Workaround*: Remove native libs that cause the JVM crash, and the
> java code reads it fine
>
> So because issue 72 is less severe, I am going to work around that
> workaround - and am thinking of removing the native libs and catching
> the IIOException Error 6 and using the old
> ImageCodec.createImageEncoder(...) to do my image conversion with JAI
> only (hopefully that will work!). If anyone thinks there is a better
> way to go about fixing this it would be much appreciated!
>
> Thanks much,
>

--
Aaron Bruegl

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Andrey Kuznetsov

Aaron,

> I am going to not use the native libs, and I catch the Error 6 Exception
> and use the old codecs to read the tiff instead and write it like so:

I already sent Brian fixes for this bug
(it was for Error 5, but they are very similar).
You have to wait a bit till he approves submission.

Andrey

--
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Aaron Bruegl

Thanks Andrey! I did not know the bugs were related. I can wait.

Andrey Kuznetsov wrote:
> Aaron,
>
>> I am going to not use the native libs, and I catch the Error 6
>> Exception and use the old codecs to read the tiff instead and write
>> it like so:
>
> I already sent Brian fixes for this bug (it was for Error 5, but they
> are very similar).
> You have to wait a bit till he approves submission.
>
> Andrey
>
> --
> http://uio.imagero.com Unified I/O for Java
> http://reader.imagero.com Java image reader
> http://jgui.imagero.com Java GUI components and utilities
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>

--
Aaron Bruegl

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Andrey Kuznetsov

> ... I did not know the bugs were related.

the bug are related as they are thrown in decodeTile(),
the first fix just catches thrown Error and skips current tile,
so the decoder can start with next tile.

Second fix checks tile size and offset, and if one of them
is 0 this tile is just skipped.

Andrey

--
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net