[GIS] Reducing File Size without losing quality

file sizegdal-translateqgis

I am using QGIS and currently have Tiff files that when uncompressed are upwards of 1 GB. When compressed, they are around 250 MB. I am trying to reduce this file size dramatically whether it be by converting to a different file type (jpeg, png) or doing something else from scratch. The Tiff files are georeferenced aerials so if I convert to jpeg or png then I will also need a world file to reference my images. The only way I have been testing this is through Raster > Conversion > Translate where I select my input layer and my output file type. I am trying to reduce these files to around 100 MB if possible.

If there is a different or better way to reduce these files let me know. The image is an example of the type of image I am using.

enter image description here

Best Answer

For aerial images like this, I suggest using TIFFs with JPEG compression. That way, there are no separate world files needed, all the metadata is stored in the TIFF as tags. Note, this will only work on RGB files with 8 bits per band.

It's lossy, so it's not suitable for DEMs (for those, lossless LZW will reduce file size by ~30 % to 40% in my experience) And keep your originals as it's impossible to regain lost quality if you lose those.

gdal_translate \
  -co COMPRESS=JPEG \
  -co JPEG_QUALITY=70 \
  -co PHOTOMETRIC=YCBCR \
  source.tif compressed.tif

JEPG_QUALITY works like the similar setting in GIMP and Photoshop. Higher quality (max. 100) means bigger files. The default is 70. The lower the number, the higher the compression.

You're unlikely to see any compression artifacts if the value is 90 or higher, unless you're a nit-picky digital photographer like me (and even then, it's a struggle to see the difference) :)

It's still lossy compression, so if you if you can't afford any data changes DEFLATE will be more suitable, at the expense of larger file sizes.

Artifacts tend to be more noticeable in areas with high contrast (like edges of buildings) so look for those when assessing quality, rather than low-contrast areas like tree canopy or fields.

There's a nice blog post on the subject by Paul Ramsey, which covers some additional settings which are suitable for certain scenarios (like serving images over web services)

Related Question