Search code examples
ubuntucompressiongdal

JPEG compression in gdal_translate: wrong JPEG library version


I tried to reduce the size of a simple hillshade geotiff by manipulating a compression switch of gdal_translate command, inspired by this great blog entry. However, running command with -co COMPRESS=JPEG results with the following well known error:

ERROR 1: JPEGLib:Wrong JPEG library version: library is 62, caller expects 80

I made sure I deleted every single instance 6- based libjpeg library and installed every possible 8-based libjpeg library, but the problem still persists. I have GDAL version 2.0.0. running on Ubuntu 16.04.1 Xenial.

Has anybody run into the same problem?

Is it the input (geotiff) or dependencies related issue?


Solution

  • Unfortunately, I haven't found a solution to the original problem, but I did find a sweet workaround to apply a JPEG compression to the TIF raster which was my original problem anyways.

    For some reason, calling a gdal_translate from within Python's GDAL API doesn't have problem with "COMPRESS=JPEG" option. So, here is what worked for me:

    from osgeo import gdal
    ds = gdal.Open("Raster.tif")
    ds = gdal.Translate("Raster_compressed.tif", ds, creationOptions=['COMPRESS=JPEG'])