[Gdal-dev] Using gdal_translate to translate from UInt32 to Byte

Frank Warmerdam warmerdam at pobox.com
Thu Jul 6 12:20:43 EDT 2006


John Preston wrote:
> Band 1 Block=200x20 Type=UInt16, ColorInterp=Gray
> Band 2 Block=200x20 Type=UInt16, ColorInterp=Undefined
> Band 3 Block=200x20 Type=UInt16, ColorInterp=Undefined
> 
> to a standard jpeg  or png that can be viewed with any image viewer. 
> Each time I try gdal_translate -of JPEG xxx.tif xxx.jpg I get the 
> following error:
> 
> ERROR 6: JPEG driver doesn't support data type UInt16. Only eight bit 
> byte bands supported.
> 
> Is their any flag that I can use to read the UInt16 blocks and combine them

John,

The "-ot Byte" flag will tell gdal_translate to convert to byte.  You will
also likely want to scale the data or else everything above 255 will be
clipped to 255.  For default scaling use:

  gdal_translate -of JPEG -scale -ot Byte xxx.tif xxx.jpg

By the way, gdal_translate options are described online in the utilities
documentation:

   http://iweb.gdal.org/gdal_translate.html

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGF, http://osgeo.org




More information about the Gdal-dev mailing list