Thursday, June 26, 2014

Python 3.4 and Pillow 2.4 with JPEG2000 (openjpeg 2) support in Ubuntu 14.04

Pillow support for JPEG2000 comes from openjpeg 2 library. Unfortunatly, Ubuntu's libopenjpeg2 package is not version 2 of the openjpeg library, but actually version 1.3 which wont work with Pillow.

Installing Pillow 2.4 (pip install -I pillow) simply results in "OPENJPEG (JPEG2000) support not available".

Thus, it is needed to compile the openjpeg library 2.0 from source. For this, first lets download the openjpeg 2.0.1:wget http://downloads.sourceforge.net/project/openjpeg.mirror/2.0.1/openjpeg-2.0.1.tar.gz

tar xzvf openjpeg-2.0.1.tar.gz
cd openjpeg-2.0.1/
cmake .
make
sudo make install


Please note that we install version of openjpeg 2.0, rather than newer 2.1. Pillow wont recognize openjpeg 2.1 either.

Assuming everything went fine, we can reinstall Pillow:pip install -I pillow
If openjpeg 2.0.1 was detected successfully, we should get the following info "OPENJPEG (JPEG2000) support available" among others.

4 comments:

  1. Seems like the install process doesn't call ldconfig properly, so you need to call it after "make install".

    Source: http://comments.gmane.org/gmane.comp.graphics.openjpeg/500

    ReplyDelete
  2. The first line of the instructions, (starting with http://downloads), is missing the command wget before the URL.

    ReplyDelete
  3. Thx. I added missing wget call to the code.

    ReplyDelete
  4. Anonymous3:25 AM

    I have this error after sudo make install

    In file included from /usr/include/png.h:536:0,
    from /home/franco/workspace/portfolio/openjpeg-2.0.1/src/bin/jp2/convert.c:51:
    /usr/include/zlib.h:1758:44: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Z_ARG’
    ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file,
    ^
    make[2]: *** [src/bin/jp2/CMakeFiles/opj_compress.dir/convert.c.o] Errore 1
    make[1]: *** [src/bin/jp2/CMakeFiles/opj_compress.dir/all] Errore 2
    make: *** [all] Errore 2

    ReplyDelete