Jframeye / thumbnailator

Automatically exported from code.google.com/p/thumbnailator
Other
0 stars 0 forks source link

Bug with TIFF images : Bits per sample must be 1 for RLE compression #50

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use Thumbnailator with a TIFF image.

What is the expected output? What do you see instead?

javax.imageio.IIOException: I/O error writing TIFF file!
    at com.sun.media.imageioimpl.plugins.tiff.TIFFImageWriter.write(TIFFImageWriter.java:2669)
    at com.sun.media.imageioimpl.plugins.tiff.TIFFImageWriter.write(TIFFImageWriter.java:2380)
    at net.coobird.thumbnailator.tasks.io.OutputStreamImageSink.write(Unknown Source)
    at net.coobird.thumbnailator.tasks.SourceSinkThumbnailTask.write(Unknown Source)
...
Caused by: javax.imageio.IIOException: Bits per sample must be 1 for RLE 
compression!
    at com.sun.media.imageioimpl.plugins.tiff.TIFFRLECompressor.encode(TIFFRLECompressor.java:116)
...

What version of the product are you using? On what operating system? Which
version of Java (Sun/Oracle? OpenJDK?) ?

v0.4.5 on Java 1.7.0_10 with 
jai-imageio-core-standalone-1.2-pre-dr-b04-2013-04-23.

Original issue reported on code.google.com by cimballi...@gmail.com on 29 Jul 2013 at 1:44

GoogleCodeExporter commented 9 years ago
Sorry for the late reply.

Thumbnailator by itself will not support TIFF images.

However, as you indicated, using external "plug-ins" to Image I/O (in this 
case, JAI), it is possible to use formats which are not supported 
out-of-the-box from the regular Java runtime.

In this case, looking at the stacktrace, the error appears to be caused by 
trying to use RLE compression with an image that is not monochrome.

It is outside the scope of the Thumbnailator project to provide support for 
using the `ImageReader`s and `ImageWriter`s that perform the actual 
decompression/compression of the images themselves.

From the information provided in this issue, I was able to find the Javadoc for 
the TIFF writer in question:
http://stain.github.io/jai-imageio-core/javadoc

In this particular issue, it appears that the compression type ("RLE") is not 
suitable for the current image.

Therefore, to resolve this particular case, the `outputCompressionType` should 
be specified to something other than RLE, and something that works with the 
current image.

An example of using `outputCompressionType` would be like:

  Thumbnails.of("path/to/image")
    .size(100, 100)
    .outputFormat("TIFF")
    .outputFormatType(compressionTypeThatWorks)
    .toFile("path/to/tiff");

-----------

I will consider this to be a case of insufficient documentation about how 
decompression/compression is handled in Thumbnailator. (i.e. Thumbnailator is 
just a wrapper around the Image I/O API.)

This issue will be merged with Issue 32, which is a similar issue regarding 
supported formats.

Original comment by coobird...@gmail.com on 8 Sep 2013 at 10:10

GoogleCodeExporter commented 9 years ago
Thanks a lot for your explanations, they help me solve the problem.

Original comment by cimballi...@gmail.com on 21 Sep 2013 at 12:19