Opened 9 years ago

Closed 9 years ago

#6153 closed defect (fixed)

gdal_translate does not respect resolution (DPI) of non-TIFF source when the target is TIFF

Reported by: mwe Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: 2.0.1
Severity: trivial Keywords: gdal_translate DPI resolution
Cc:

Description

gdal_translate (version 1.X and 2.X) does not respect resolution (DPI) of non-TIFF source when the target is TIFF.

Example:

map.jpg with 300 DPI

GDAl 1.x: gdal_translate -a_srs '+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=7 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.180918 +units=m +no_defs' 'map.jpg' 'map.tif'

GDAl 2.x: gdal_translate -tr 300 300 -a_srs '+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=7 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.180918 +units=m +no_defs' 'map.jpg' 'map.tif'

The metadata of the resulting map.tif contains 72 DPI.

If the source is a 300 DPI TIFF file, then the result has the correct resolution.

Attachments (1)

map.jpg (313.5 KB ) - added by mwe 9 years ago.
JPEG with 300 DPI

Download all attachments as: .zip

Change History (4)

by mwe, 9 years ago

Attachment: map.jpg added

JPEG with 300 DPI

comment:1 by Jukka Rahkonen, 9 years ago

I believe that the title is wrong because GDAL JPEG driver does not even read the DPI metadata. It is not mentioned in http://www.gdal.org/frmt_jpeg.html and it does not appear in gdalinfo report:

gdalinfo map.jpg
Driver: JPEG/JPEG JFIF
Files: map.jpg
Size is 3377, 2711
Coordinate System is `'
Image Structure Metadata:
  COMPRESSION=JPEG
  INTERLEAVE=PIXEL
  SOURCE_COLOR_SPACE=YCbCr
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 2711.0)
Upper Right ( 3377.0,    0.0)
Lower Right ( 3377.0, 2711.0)
Center      ( 1688.5, 1355.5)
Band 1 Block=3377x1 Type=Byte, ColorInterp=Red
  Overviews: 1689x1356, 845x678, 423x339
  Image Structure Metadata:
    COMPRESSION=JPEG
Band 2 Block=3377x1 Type=Byte, ColorInterp=Green
  Overviews: 1689x1356, 845x678, 423x339
  Image Structure Metadata:
    COMPRESSION=JPEG
Band 3 Block=3377x1 Type=Byte, ColorInterp=Blue
  Overviews: 1689x1356, 845x678, 423x339
  Image Structure Metadata:
    COMPRESSION=JPEG

Thus this is not a bug but a missing feature. If you want to write the DPI tags into GeoTIFF you can use the -mo option of gdal_translate http://www.gdal.org/gdal_translate.html but you must set manually the XRESOLUTION and YRESOLUTION values.

comment:2 by mwe, 9 years ago

JPEG was only an example. The same occurs with PNG. gdal_translate -mo 'TIFFTAG_XRESOLUTION=300' -mo 'TIFFTAG_YRESOLUTION=300' -a_srs '+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=7 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.180918 +units=m +no_defs' 'map.jpg' 'map.tif' works :) You can close this issue.

comment:3 by mwe, 9 years ago

Resolution: fixed
Status: newclosed
Version: unspecified2.0.1
Note: See TracTickets for help on using tickets.