Isotr0py / pillow-jpegxl-plugin

Pillow plugin for JPEG-XL, using Rust for bindings.
GNU General Public License v3.0
20 stars 5 forks source link

panic error #43

Closed paolobenve closed 5 months ago

paolobenve commented 5 months ago

In my app using pillow-jxl-plugin:

  File "/home/paolo/git/myphotoshare/scanner/PhotoAlbum.py", line 5299, in save_image
    image.save(file_name_with_path, quality=quality, exif=True)
  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2439, in save
    save_handler(self, fp, filename)
  File "/home/paolo/git/myphotoshare/scanner/venv3.12/lib/python3.12/site-packages/pillow_jxl/JpegXLImagePlugin.py", line 132, in _save
    data = enc(
           ^^^^
pyo3_runtime.PanicException: called `Option::unwrap()` on a `None` value

Actually (and weirdly) the image which triggers the error is a jpg one...

Isotr0py commented 5 months ago

I can't reproduce this with test/images/sample.jpg using latest release version:

img_ori = Image.open("test/images/sample.jpg")
img_ori.save(temp, quality=98)

Can you provide more details about the image and using version?

paolobenve commented 5 months ago

ok, I revised better my code, it's different:

File "/home/paolo/git/myphotoshare/scanner/PhotoAlbum.py", line 5299, in save_image
    image.save("prova.jxl", quality=50, exif=None)
  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2439, in save
    save_handler(self, fp, filename)
  File "/home/paolo/git/myphotoshare/scanner/venv3.12/lib/python3.12/site-packages/pillow_jxl/JpegXLImagePlugin.py", line 132, in _save
    data = enc(
           ^^^^
pyo3_runtime.PanicException: called `Option::unwrap()` on a `None` value

The culprit seems to be the "exif=None" parameter, removing it solves the crash.

AFAIK, saving with all the other formats accept "exif=None". My code used it without any problem. I'd suggest to manage this case in the plugin, too.

Isotr0py commented 5 months ago

45 should fix this, I will release a new version later.

Isotr0py commented 5 months ago

I has released version v1.2.4 to fix this, please feel free to reopen this issue if encountered issue :)

paolobenve commented 5 months ago

thank you!