image-js / tiff

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

This is a fatal error occured in decoding big image #25

Open carbon-lab opened 3 years ago

carbon-lab commented 3 years ago

Error message: Uncaught TypeError: Cannot read property 'length' of undefined at TIFFDecoder.readStripData (.../node_modules/tiff/lib/tiffDecoder.js:180:42) at TIFFDecoder.decodeImageData (.../node_modules/tiff/lib/tiffDecoder.js:151:22) at TIFFDecoder.decodeIFD (.../node_modules/tiff/lib/tiffDecoder.js:100:18) at TIFFDecoder.decode (.../node_modules/tiff/lib/tiffDecoder.js:54:30) at Object.decodeTIFF [as decode] (.../node_modules/tiff/lib/index.js:10:20) This error appeared when I decode a very big image (21600 x 21600 px).

carbon-lab commented 3 years ago

The error message is: Uncaught TypeError: Cannot read property 'length' of undefined at TIFFDecoder.readStripData (/root/Pictures/work/node_modules/tiff/lib/tiffDecoder.js:180:42) at TIFFDecoder.decodeImageData (/root/Pictures/work/node_modules/tiff/lib/tiffDecoder.js:151:22) at TIFFDecoder.decodeIFD (/root/Pictures/work/node_modules/tiff/lib/tiffDecoder.js:100:18) at TIFFDecoder.decode (/root/Pictures/work/node_modules/tiff/lib/tiffDecoder.js:54:30) at Object.decodeTIFF [as decode] (/root/Pictures/work/node_modules/tiff/lib/index.js:10:20)

targos commented 3 years ago

Please provide us an image that triggers this error and we'll look into it.

carbon-lab commented 3 years ago

I am so sorry about that. The image is not public at first and its size is 300MB+ so how to send it?

targos commented 3 years ago

I'm asking because I tried with a 25000 x 25000 px image created with Photoshop (RGB with a color gradient, compressed with LZW). The image is >300MB and did not generate an error

carbon-lab commented 3 years ago

Yes, you're right. I also test it by a image created by photoshop (8-bit grey color, uncompressed) and did not generate an error. May be that image file is not standard. But I can use python to open it...

targos commented 3 years ago

If you cannot share it privately with me (my email address is public on my profile if you can send me a link), I can only suggest to try and debug on your side to understand why it errors.

carbon-lab commented 3 years ago

That's a good idea! Now I have locate the error at tiff/lib/tiffDecoder.js:180:42. The stripOffsets.length is not defined. What is stripOffsets?

carbon-lab commented 3 years ago

I have upload the image to this link. It's a TIFF file compressed by xz. [Above link] https://cowtransfer.com/s/e5e04f122e0649

Please download it in 24 hours. Or it will be expired.

targos commented 3 years ago

Thank you. We found why this image doesn't work. It's because the data is stored as tiles instead of strips. I found a small public image that can be used as a test case and will work on it. I cannot guarantee when that will happen though.

carbon-lab commented 3 years ago

You're welcome! I am very fortunate to be able to help you. If there is any need for further help from me, please contact me. It is very meaningful to develop a convenient graphics library for node.js.