No JPEG support

59 views
Skip to first unread message

PM 2Ring

unread,
Apr 15, 2022, 3:33:43 AM4/15/22
to sage-cell
I recently noticed that PIL in SageMathCell no longer supports loading or saving of JPEG files. Here's a short demo: https://sagecell.sagemath.org/?z=eJxTVgjw9FHwCnB1VyhJLS7hSivKzwULZeYW5BeVKHjmJqancmXmpivYQth6eanlGupB7k7qOgoaZiY6CmYmmjoKyfk5-UW26sppiQbqmlzKQPV6xYllqRrqIEP1CvLSgaJoglkFQEEAb98mQQ==&lang=sage

Pillow needs to be compiled with JPEG support enabled, as mentioned here:

I have older scripts that use JPEG which no longer work, but I don't know when they stopped working.

Andrey Novoseltsev

unread,
Apr 17, 2022, 12:10:58 PM4/17/22
to sage-cell
It seems this support was dropped in SageMath itself 6 years ago: https://trac.sagemath.org/ticket/20021

I prefer not to patch any "dependencies" without a very good reason - SageMath is installed from source in a standard way into a system with a bunch of system-packages preinstalled. I am happy to add more system-packages or more pip packages into SageMath install. But fiddling with SageMath source/install files used to cause a bunch of issues and I don't want to return to it.

Given that there were no complaints about jpeg support in 6 years and it is possible to use other formats, I'd say it is a feature. To "fix" it, one can increase build requirements for SageMath and adjust its installation scripts.

kcrisman

unread,
Apr 17, 2022, 8:48:19 PM4/17/22
to sage-cell
However, you (original poster) can ask at the sage-devel or sage-support list whether this could potentially be re-enabled (presumably it was done because not every computer has the right jpeg library).  I actually ran into this myself just a few weeks ago - sometimes one doesn't use materials for closer to a decade :)

PM 2Ring

unread,
Apr 18, 2022, 4:46:00 AM4/18/22
to sage-cell
Ah, ok. 

My old scripts that successfully used JPEG were from March 2021, not 6 years ago, unless I'm imagining things. ;) I've only been using Sage / SageMathCell since September 2020 (I discovered it via https://www.math-cs.gordon.edu/~kcrisman/mat338/NTIC.html).

FWIW, lack of JPEG in Pillow is a fairly common problem:  https://stackoverflow.com/q/8915296/4014959

Lately I've been exploring image processing with scipy & skimage. It would be nice to load jpeg images. I mostly use SageMathCell on my Android phone.  

Andrey Novoseltsev

unread,
Apr 18, 2022, 1:41:35 PM4/18/22
to sage-cell

PM 2Ring

unread,
Apr 19, 2022, 12:24:36 AM4/19/22
to sage-cell
Thanks, Andrey. Much appreciated.

I have my fingers crossed. :)

PM 2Ring

unread,
Jun 22, 2022, 12:51:18 PM6/22/22
to sage-cell
Ok! We now have JPEG support. My test script above now works.
I assume reading JPEG also works. ;)
Thanks to all who made this happen.

Andrey Novoseltsev

unread,
Jun 22, 2022, 4:25:52 PM6/22/22
to sage-cell
I actually don't understand what has happened --disable-jpeg is still in the install script:

Although it seems that Sage installs version 9.0.1, but we actually have 9.1.1, so it got upgraded and perhaps gained jpeg support in the process... In which case it may disappear again in the future.

Reply all
Reply to author
Forward
0 new messages