[gdal-dev] TIF + TFW to GeoTIFF without decompression/recompression
Andrea Giudiceandrea
andreaerdna at libero.it
Mon Sep 20 02:11:14 PDT 2021
Hi devs,
gdal_transalte has an "hidden" feature (not mentioned in the docs [1]),
introduced since GDAL 1.10 [2], which allows to convert .JPG + .JPW
raster layer to GeoTIFF without decompressing and recompressing the
raster image (a so called "lossless conversion of JPEG into
JPEG-in-TIFF" [3]).
It seem to me the same is not possible if the source is a .TIF (e.g. a
JPEG-in-TIFF) + .TFW raster layer. In this case the image is always
decompressed and then recompressed if a compression method is specified,
thus adding another unnecessary lossy step.
I think the decompression / recompression cycle should obviously not be
needed converting a TIFF file to a GeoTIFF file (unless image
manipulation options are specified) and gdal_transalte should just copy
the source TIF file and add the proper GeoTIFF metadata tags taken from
the TFW file and from the -a_srs parameter.
Maybe is there any other "hidden" feature I haven't been able to find yet?
Best regards.
Andrea Giudiceandrea
[1] https://github.com/OSGeo/gdal/issues/4510
[2]
https://github.com/OSGeo/gdal/commit/a77c726484d508f1ffff2b9f5a9a869313092687
[3]
https://erouault.blogspot.com/2014/04/advanced-jpeg-in-tiff-uses-in-gdal.html
Side notes:
I know gdal_edit could also be used, but it cannot automatically take
the georeferencing parameters from the TFW file.
It could also be possible to use the geotifcp cli tool from libgeotiff,
but it seems it (the one shipped by OSGeo4W) has some issues handling
JPEG-in-TIFF files (while it works well with other compression formats):
the "Warning, fractional scanline discarded." and "JPEGLib: Application
transferred too few scanlines." errors are reported unsuccessfully
trying to convert a JPEG-in-TIFF + TFW to a GeoTIFF.
Instead, the very old and almost nowhere to be found GeoTiffExamin gui
tool can just add the proper GeoTIFF metadata tags, taken from the TFW
file, to a TIFF file without modifying the raster image. Anyway the gui
tool cannot be used for batch conversion.
More information about the gdal-dev
mailing list