Pillow and JPEG2000: decoder jpeg2k not available
Asked Answered
L

3

6

I'm trying to set up Flask-IIIF to work with jp2-files, or JPEG2000. Right out of the box I get an error from the Pillow library: IOError: decoder jpeg2k not available

I've tried googling it, and one StackOverflow post told me to make sure libjpeg-dev and libjpeg8-dev are installed and up to date, but they were already installed. After making sure they were there, I did try to reinstall pillow without cache: pip install --no-cache-dir -I pillow

The environment is Docker, based on a 15.10 Ubuntu image. Python version is 2.7.10. Pillow version from pip freeze is 4.1.1

edit: I also tried the other suggestion of Python Image Library fails with message "decoder JPEG not available" - PIL:

sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib

Latimore answered 27/6, 2017 at 14:15 Comment(0)
H
3

Pillow needs the OpenJPEG library to decode JPEG2000 files. libjpeg only deals with regular JPEGs.

See the note in the Pillow docs at the end of this section: http://pillow.readthedocs.io/en/latest/handbook/image-file-formats.html#jpeg-2000

Homocentric answered 27/6, 2017 at 22:24 Comment(0)
D
8

for linux

sudo yum install -y libjpeg-devel
sudo pip uninstall pillow
sudo pip install pillow

for windows

# download
import imageio
imageio.plugins.freeimage.download()
# install
pip uninstall pillow
pip install pillow
Devilmaycare answered 9/7, 2020 at 5:44 Comment(0)
H
3

Pillow needs the OpenJPEG library to decode JPEG2000 files. libjpeg only deals with regular JPEGs.

See the note in the Pillow docs at the end of this section: http://pillow.readthedocs.io/en/latest/handbook/image-file-formats.html#jpeg-2000

Homocentric answered 27/6, 2017 at 22:24 Comment(0)
S
2

Windows users: After you installed OpenJPEG and added its bin folder to PATH, you need to re-build the pillow library. Using Conda I didn't find a solution to do that so I ended up using the windows installer from PyPi as suggested in this answer here. The installer found my Anaconda installation and it seems it simply overwrote the pillow library there.

Statolatry answered 14/1, 2019 at 13:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.