xlhomme / GeotiffParser.js

A JavaScript-based parser for the GeoTIFF image format.
Mozilla Public License 2.0
46 stars 15 forks source link

Invalid array length when decompressing in lz-string.js #5

Open agustinbus opened 7 years ago

agustinbus commented 7 years ago

Hi, first of all sorry for my bad english. I'm ussing a mapping software that generates geotiff files. One of that files generate a .tif with low resolution (and without compression), and the another file is compressed with lzw (i know it because i'm using the method consoleTiffProperty). With the first file (unompressed) i have no problem with processing the geotiff and showing it, but when i try with the second file (compressed with lzw) i have an decompression error in lz-string.js library (Files are not corrupted because i can open it in qGis with no problem). This is the console output of the error in my browser:

lz-string.js:301 Uncaught RangeError: Invalid array length
    at Object.decompressFromUint8Array (lz-string.js:301)
    at GeotiffParser.decodeBlock (GeotiffParser.js:1053)
    at GeotiffParser.getClosestPixelValue (GeotiffParser.js:1434)
    at GeotiffParser.getPixelValueOnDemand (GeotiffParser.js:1484)
    at GeotiffParser.loadPixels (GeotiffParser.js:1214)
    at LoadGeotiffParser (testGeotiffParser.js:72)
    at FileReader.reader.onload (loadtiff.js:21)

Its seems the error is because on line 301 the result of compression.lenght/2 is decimal (i output length variable and is = 33, so 33/2 = 16.5). I try to hardcode the result of compression.lenght/2 to 17, and the error gones, but if i do that then i have the following error:

Uncaught TypeError: Cannot read property '0' of undefined
    at GeotiffParser.loadPixels (GeotiffParser.js:1216)
    at LoadGeotiffParser (testGeotiffParser.js:72)
    at FileReader.reader.onload (loadtiff.js:21)

Cannot read property 0 of undefined, i output the buffer result after String.fromCharCode in decompressFromUint8Array() method and i got an empty string

Im, don't know if an issue but i can get it work. Please any help is appreciated, thanks in advance

xlhomme commented 7 years ago

Hi Thanks for submitting this issue. Feel free to suggest correction. I m not have sufficient free time to work bon this project yet. Best regards

Le 19 avr. 2017 01:58, "agustinbus" notifications@github.com a écrit :

Hi, first of all sorry for my bad english. I'm ussing a mapping software that generates geotiff files. One of that files generate a .tif with low resolution (and without compression), and the another file is compressed with lzw (i know it because i'm using the method consoleTiffProperty). With the first file (unompressed) i have no problem with processing the geotiff and showing it, but when i try with the second file (compressed with lzw) i have an decompression error in lz-string.js library. This is the console output of the error in my browser:

lz-string.js:301 Uncaught RangeError: Invalid array length at Object.decompressFromUint8Array (lz-string.js:301) at GeotiffParser.decodeBlock (GeotiffParser.js:1053) at GeotiffParser.getClosestPixelValue (GeotiffParser.js:1434) at GeotiffParser.getPixelValueOnDemand (GeotiffParser.js:1484) at GeotiffParser.loadPixels (GeotiffParser.js:1214) at LoadGeotiffParser (testGeotiffParser.js:72) at FileReader.reader.onload (loadtiff.js:21)

Its seems the error is because on line 301 the result of compression.lenght/2 is decimal (i output length variable and is = 33, so 33/2 = 16.5). I try to hardcode the result of compression.lenght/2 to 17, and the error gones, but if i do that then i have the following error:

Uncaught TypeError: Cannot read property '0' of undefined at GeotiffParser.loadPixels (GeotiffParser.js:1216) at LoadGeotiffParser (testGeotiffParser.js:72) at FileReader.reader.onload (loadtiff.js:21)

Cannot read property 0 of undefined, i output the buffer result after String.fromCharCode in decompressFromUint8Array() method and i got an empty string

Im, don't know if an issue but i can get it work. Please any help is appreciated, thanks in advance

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/xlhomme/GeotiffParser.js/issues/5, or mute the thread https://github.com/notifications/unsubscribe-auth/ADzU5K06OuGceUVg0oGtjP33m7BpEsewks5rxU4hgaJpZM4NBCW7 .