MKS
MKS

Reputation: 199

Python Image Library fails with message “IOError: decoder jpeg not available” - PIL when compile in SageMath Notebook

I'm facing an strange problem with PIL. Whenever I am compiling the following code with python everything is ok:

from PIL import Image
file=Image.open("si.jpg") 
file2=file.convert("L")
pix = file2.load()
print pix
colsize,rowsize=file2.size
for i in range(rowsize):
    for j in range(colsize): 
        if pix[j,i]>250:
            pix[j,i]=250
file2.save("ci2.pgm")

But when I compile the above code in SageMath Notebook, it gives an error “IOError: decoder jpeg not available”. Here is the scrrenshot :
enter image description here I have found a similar problem here, but these solution does not work for me. My OS is Ubuntu 16.04 (32bit). The image link :enter image description here) I want to get solution for SageMath. How do I solve this issue?

Upvotes: 1

Views: 487

Answers (1)

Samuel Lelièvre
Samuel Lelièvre

Reputation: 3453

It seems your version of the Python package "Pillow" (the Python Image Library) is missing the decoder for jpg.

To install it, quit Sage, and in a terminal, run the following:

$ sudo apt-get install libjpeg-dev
$ sage --pip install --no-cache-dir -I pillow

Then restart Sage and try running your code again.

Upvotes: 1

Related Questions