geotiffjs / geotiff.js

geotiff.js is a small library to parse TIFF files for visualization or analysis. It is written in pure JavaScript, and is usable in both the browser and node.js applications.
https://geotiffjs.github.io/
MIT License
866 stars 182 forks source link

image.readRasters() #404

Open pChao3 opened 11 months ago

pChao3 commented 11 months ago

i use this api, but the res is [2268,2910,2112,1850,...] i need help..

constantinius commented 11 months ago

With that little detail it is hard to see what you try to achieve, how you go about it and where you need help. Please provide more details, otherwise I'll have to close this issue.

pChao3 commented 11 months ago

I apologize for the previous incomplete information. The issue I'm encountering is that the image.readRasters() method returns an array structured as Uint16Array, with four-digit values. I aim to obtain a Uint8Array structured array, containing values within the range of 0 to 255. Upon reviewing relevant documentation, it seems there's no mention of any parameters within the API to modify the structure of the returned array. Hence, I wanted to ask if this API allows for parameter adjustment to change the structure of the returned array?

constantinius commented 10 months ago

It looks like you want to get RGB data from the TIFF. If that is correct, please use the readRGB method instead.

readRasters will always return the "actual" data, which may be in any value space or datatype the underlying TIFF provides. You have to adjust the result accordingly for your usecase.

Again, this is very little information. The library seems to perform as expected and the results are according to the capabilities and documentation.