Opened 9 years ago

Closed 9 years ago

#5869 closed defect (invalid)

gdal_translate from GeoTIFF to PNG switches to 8 bits and truncates

Reported by: benl Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: 1.11.2
Severity: normal Keywords:
Cc:

Description

If I download this map:

http://srtm.csi.cgiar.org/SRT-ZIP/SRTM_V41/SRTM_Data_GeoTiff/srtm_36_02.zip

and translate the tif like so:

gdal_translate -of png srtm_36_02.tif srtm_36_02.png

I get this error:

Warning 6: PNG driver doesn't support data type Int16. Only eight bit (Byte) and sixteen bit (UInt16) bands supported. Defaulting to Byte

Possibly because the tif contains some negative elevation values. In my own code where I offset by the minimum, I can generate a 16 bit PNG just fine.

Change History (5)

comment:1 by Even Rouault, 9 years ago

Resolution: invalid
Status: newclosed

You can use the -scale option to do any scaling/offseting you like.

comment:2 by benl, 9 years ago

Resolution: invalid
Status: closedreopened

This may be true, but surely the default should be to produce a correct PNG? As well as going down to 8 bits, it truncates all the high ground.

comment:3 by Even Rouault, 9 years ago

If you use gdal_translate -strict, the warning is an error and no file is generated. There's no other automated behaviour we can have that will please everybody. Honestly I don't see any further action that could be done on this ticket. A warning is emitted, so you're aware that something might not be OK.

comment:4 by lpinner, 9 years ago

@benl - I don't think Int16 is a valid bit depth for single channel greyscale PNGs (http://www.w3.org/TR/PNG), UInt16 is valid though, so if you must output a 16bit PNG, use something like:

gdal_translate -ot UInt16 -of png srtm_36_02.tif srtm_36_02.png

comment:5 by Even Rouault, 9 years ago

Resolution: invalid
Status: reopenedclosed
Note: See TracTickets for help on using tickets.