[gdal-dev] how to convert UInt16 Tiff

Even Rouault even.rouault at mines-paris.org
Tue Apr 24 03:38:44 EDT 2012


>
> thanks for the reply, I did try with NBITS=8 and 12 with osgeo4w's gdal
> and tamas' nightly build but the output results are incorrect
>
> Here is a sample file (93Mo) :
> http://dl.free.fr/iFT4hH3Yj
>
> I'll try to rebuild gdal on my linux box with the internal libs

I haven't looked at your result image, but you cannot just specify NBITS=8 or
12, if the range of the values in the original file is full 16 bits.

You need to rescale the values, otherwise they will get clamped to [0, 255] or
[0, 4096].

So you can look for the min/max reported by gdalinfo -mm
uncompressed_original.tif

and then try :

gdal_translate -co "COMPRESS=JPEG" uncompressed_original.tif compressed.tif
-scale min max 0 255 -ot Byte

or

gdal_translate -co "COMPRESS=JPEG" uncompressed_original.tif compressed.tif
-scale min max 0 4095 -co NBITS=12



More information about the gdal-dev mailing list