Help with saving images using lossless jpeg compression


Varisht Ghedia
 

Hi,

While saving transformed and cut geotiff files to local filesystem, I wanted to save them in a lossless format. Currently, I use the "GTiff" driver to save the rasters in a tif format. While this does preserve the data, the file size is quite large (60MB~100MB). On saving them in a compressed format using JPEG a lot of quality is lost and the images lack the original details. Is there a provision to save these rasters in a different lossless format which is lighter and offers good compression? I explored lossless jpeg compression and wanted to use it. What is the right way to implement this?

Thanks and regards,
Varisht Ghedia


Idan Miara
 

Hi Ghedia, 

Try Deflate or LZW compression. 


On Wed, 8 Sep 2021, 14:47 Varisht Ghedia, <varisht@...> wrote:
Hi,

While saving transformed and cut geotiff files to local filesystem, I wanted to save them in a lossless format. Currently, I use the "GTiff" driver to save the rasters in a tif format. While this does preserve the data, the file size is quite large (60MB~100MB). On saving them in a compressed format using JPEG a lot of quality is lost and the images lack the original details. Is there a provision to save these rasters in a different lossless format which is lighter and offers good compression? I explored lossless jpeg compression and wanted to use it. What is the right way to implement this?

Thanks and regards,
Varisht Ghedia


Sean Gillies
 

Hi,

Lossless JPEG compression is only possible with the JPEG2000 format drivers. It's not an option for GeoTIFF.

See https://gdal.org/drivers/raster/jp2openjpeg.html#lossless-compression for the details. There are 4 other JPEG2000 format drivers for GDAL and they may have different options.


On Wed, Sep 8, 2021 at 6:47 AM Varisht Ghedia <varisht@...> wrote:
Hi,

While saving transformed and cut geotiff files to local filesystem, I wanted to save them in a lossless format. Currently, I use the "GTiff" driver to save the rasters in a tif format. While this does preserve the data, the file size is quite large (60MB~100MB). On saving them in a compressed format using JPEG a lot of quality is lost and the images lack the original details. Is there a provision to save these rasters in a different lossless format which is lighter and offers good compression? I explored lossless jpeg compression and wanted to use it. What is the right way to implement this?

Thanks and regards,
Varisht Ghedia


--
Sean Gillies