libvips / pyvips

python binding for libvips using cffi
MIT License
649 stars 50 forks source link

class "jxlsave" not found #467

Open euzada opened 6 months ago

euzada commented 6 months ago

Hi @jcupitt,

I tried to save an image as jpeg XL but getting the following error:

pyvips.error.Error: no such operation jxlsave
  VipsOperation: class "jxlsave" not found

I compiled libvips for windows with ./build.sh --with-jpegli but didn't work. I saw that since version v8.11.0 that Add libjxl to 'all' group dependencies for JPEG XL support (https://github.com/libvips/build-win64-mxe/pull/28).. I used 'all' version and still having the same issue. I cannot use jxlsave in pyvips.

pyvips version = 2.2.3 libvips version = vips-8.15.2

Any suggestion?

jcupitt commented 6 months ago

Hello @euzada,

Did you try the official win binary? It should include jxlsave.

https://github.com/libvips/build-win64-mxe/releases/tag/v8.15.2

You need 8.15.2 w64 all.

euzada commented 6 months ago

Hello @euzada,

Did you try the official win binary? It should include jxlsave.

https://github.com/libvips/build-win64-mxe/releases/tag/v8.15.2

You need 8.15.2 w64 all.

Yes I did. getting the following error:


  jxlsave: error JxlEncoderProcessOutput```
jcupitt commented 6 months ago

Oh, strange, let me try here.

jcupitt commented 6 months ago

I tried on a win10 VM and it seems to work:

jcupi@DESKTOP-HGI6HBR MINGW64 /f/Pictures
$ ../vips-dev-8.15/bin/vips.exe copy DL-742.png x.jxl

jcupi@DESKTOP-HGI6HBR MINGW64 /f/Pictures
$ ../vips-dev-8.15/bin/vips.exe --version
vips-8.15.0

And the image seems fine. I'll try with the latest build.

kleisauke commented 6 months ago

jxlsave: error JxlEncoderProcessOutput

I could not reproduce this with the vips-dev-w64-all-8.15.2.zip binaries on my Windows 11 PC.

$ python
Python 3.12.3 (tags/v3.12.3:f6650f9, Apr  9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvips
>>> ref = pyvips.Image.new_from_file('zebra.jpg')
>>> ref.jxlsave('x.jxl', lossless=True)
>>> x = pyvips.Image.new_from_file('x.jxl', access='sequential')
>>> (ref - x).abs().max()
0.0
>>>
euzada commented 6 months ago

Hi,

I figure it out. I am having this image only for output image larger than 10kx10k image. For smaller images, it works, for larger it said jxlsave not found.

jcupitt commented 6 months ago

Could it be running out of memory? Until very recently, libjxl could use HUGE amounts of ram for larger images.

vipsdisp 3.0.4 for win is built against a recent libjxl. It could be worth checking memuse for that program when saving a large JXL image.

kleisauke commented 6 months ago

Indeed, it sounds like an OOM error. I was able to create a 100000x100000 image without any issues.

$ python
Python 3.12.3 (tags/v3.12.3:f6650f9, Apr  9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvips
>>> x = pyvips.Image.black(100000, 100000, bands=3)
>>> x.jxlsave('x.jxl')
>>> pyvips.Image.new_from_file('x.jxl', access='sequential')
<pyvips.Image 100000x100000 uchar, 3 bands, srgb>
>>>
jcupitt commented 6 months ago

I tried making a JXL image with libjxl 0.7:

$ /usr/bin/time -f %M:%e vips replicate nina.jpg x.jxl 2 3 
10983132:22.56

That's 11gb of memory for a 12k x 12k image. With 0.10.1 I see:

$ /usr/bin/time -f %M:%e vips replicate nina.jpg x.jxl 2 3 
1314856:70.23

A more reasonable 1.3gb, though it's noticeably slower for some reason.