JPEG compression in gdal_translate: wrong JPEG library version

867 Views Asked by At

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?

2

There are 2 best solutions below

0
On BEST ANSWER

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'])
2
On

Check what libraries are referenced from gdal_translate:

ldd /bin/gdal_translate
ldd /bin/gdal_translate | grep jpeg

Check where are your library symlinks pointing at, as described here:

List all files in your library folders and grep for the library you are lloking for:

cd /usr/lib64/
ls -la | grep jpeg

cd /usr/local/lib
ls -la | grep jpeg

cd /usr/lib
ls -la | grep jpeg

Make sure all your symlinks are pointing to the right version:

lrwxrwxrwx  1 root root       17 Mar  8 09:54 libjpeg.so -> libjpeg.so.62.0.0*

Should be

lrwxrwxrwx  1 root root       17 Mar  8 09:54 libjpeg.so -> libjpeg.so.8.3.0*

Install the libraries that provide the correct version or create the symlinks manually.