image-js / tiff

TIFF image decoder written entirely in JavaScript
MIT License
190 stars 17 forks source link

Deflate compression supported? #23

Closed anieuwland closed 3 years ago

anieuwland commented 3 years ago

Hello! We are trying to read a TIFF compressed with the deflate algorithm. Unfortunately, it fails with the following error. I can't seem to find whether this library does or does not support deflate. Could you provide some details on the state of it and whether there are plans to support it?

It would help us knowing whether the image is somehow malformed or otherwise.

Uncaught (in promise) Error: invalid compression: 8
    readStripData tiffDecoder.js:195
    decodeImageData tiffDecoder.js:145
    decodeIFD tiffDecoder.js:94
    decode tiffDecoder.js:48
    decodeTIFF index.js:4
    loadTIFF load.js:144
    loadBinary load.js:48
    load load.js:31
    convertReturnImage ImageUploader.vue:284
    upload ImageUploader.vue:370
    promise callback*upload ImageUploader.vue:368
    VueJS 4
    clickButton vuesax.common.js:1657
    click vuesax.common.js:1529
    VueJS 33
targos commented 3 years ago

Hi. The deflate compression is not supported yet, mostly because we never had an image that used it. If you have an image in this format that you are able to share publicly (to be used in the unit tests), we can look into it. I think it will probably be easy to add support for it using the pako library, as we did for the PNG decoder.

anieuwland commented 3 years ago

That's great to hear! We are using the following image to develop with, only zipped up as an extra step here because Github doesn't allow tif files. The tif inside is also deflate compressed. Does this suffice? tile_rgb_deflate.zip

targos commented 3 years ago

Thanks for the sample. This was indeed easy to implement! I just published v4.3.0 with Zlib/deflate support.

anieuwland commented 3 years ago

Wow, that was quick, thanks a lot! We successfully decoded our deflate compressed images.