[gdal-dev] how to convert UInt16 Tiff

jr.morreale at enoreth.net jr.morreale at enoreth.net
Tue Apr 24 04:53:00 EDT 2012


On Tue, 24 Apr 2012 09:38:44 +0200, Even Rouault wrote:
>>
>> 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

Thanks, I didn't knew that !

The man says that you can omit the input min max scale so gdal computes 
it for each source, however I can't find how to write that correctly


More information about the gdal-dev mailing list