pythonimagetiffopenslide

Unsupported TIFF Compression


I'm using openslide-python to open a svs image, and I have run into the following issue:

>> import openslide as osi
>> a = osi.OpenSlide('image.svs')

yields the error

TIFFReadDirectory: Warning, Unknown field with tag 347 (0x15b) encountered.
image.svs: JPEG compression support is not configured.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/manan/anaconda/lib/python2.7/site-packages/openslide/__init__.py", line 154, in __init__
    self._osr = lowlevel.open(filename)
  File "/home/manan/anaconda/lib/python2.7/site-packages/openslide/lowlevel.py", line 178, in _check_open
    raise OpenSlideError(err)
openslide.lowlevel.OpenSlideError: Unsupported TIFF compression: 7

I haven't been able to find any solutions online for this issue; I've checked libopenjpeg and any additional relevant libraries to ensure they are at their latest respective versions.


Solution

  • If you look at the code: https://github.com/openslide/openslide/blob/7b99a8604f38280d14a34db6bda7a916563f96e1/src/openslide-vendor-generic-tiff.c#L222-L226

    if (!TIFFIsCODECConfigured(compression)) {
      g_set_error(err, OPENSLIDE_ERROR, OPENSLIDE_ERROR_FAILED,
                  "Unsupported TIFF compression: %u", compression);
      goto FAIL;
    }
    

    You will see that it uses libtiff: the function TIFFIsCODECConfigured is provided by the underlying libtiff library (see man page).

    The compression tag is set to 7; this is the uncommonly supported JPEG ('new-style' JPEG) compression scheme - sometimes also referred as JPEG-in-TIFF; which you need to install a codec for.

    If you still have the slides and used e.g. Kodak Imaging, then you may be able to scan them again with a different compression; but that would be a back-and-around way. It probably is easier to try and add the codec and enable it in libtiff.

    From libtiff documentation:

    Support for JPEG compression is controlled by JPEG_SUPPORT. The JPEG codec that comes with libtiff is designed for use with release 5 or later of the Independent JPEG Group's freely available software distribution. This software can be retrieved from the directory ftp.uu.net:/graphics/jpeg/.

    So the support is optional, and you may need to rebuild libtiff (see instructions).

    By default JPEG support is not configured.

    References: