dragon66 / icafe

Java library for reading, writing, converting and manipulating images and metadata
Eclipse Public License 1.0
204 stars 58 forks source link

Tiff compression setting not honored #62

Closed ben-manes closed 6 years ago

ben-manes commented 6 years ago

An integration partner requested that we use CCITTFAX Group 4, which you implemented. However, they said that it the sample file was in fact PACKBITS. Using imagemagik identify --verbose it merely says RLE.

Digging into the code, TIFFWriter.java#L679 appears to reset the compression. One would assume either (a) a failure or (b) the setting was honored and the image downgraded. Instead if the ImageParam is not set with ImageColorType.BILEVEL then it is upgraded to PACKBITS.

I believe honoring the user's settings would follow the principle of least astonishment.

dragon66 commented 6 years ago

@ben-manes I have done some changes to check supported compression types for each image type. If certain compression type is not supported by the image type, an UnsupportedCompressionException will be thrown instead of falling back to PackBits compression.

ben-manes commented 6 years ago

Thanks, looks good!