8000 Include JXL as Foreign TIFF Compression · Issue #3951 · libvips/libvips · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Include JXL as Foreign TIFF Compression #3951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jcupitt opened this issue May 2, 2024 Discussed in #3818 · 11 comments
Open

Include JXL as Foreign TIFF Compression #3951

jcupitt opened this issue May 2, 2024 Discussed in #3818 · 11 comments

Comments

@jcupitt
Copy link
Member
jcupitt commented May 2, 2024

Discussed in #3818

Originally posted by AngelaDMerkel January 17, 2024
Libvips struggles to properly handle metadata when moving between TIFF and JXL. Allowing JXL as foreign compression much like it does JPEG would help to realise many of the lossless space savings of JXL alongside the wide feature set of TIFF— without needing to compromise on metadata quality.
There is some precedent for this by Adobe. Adobe is using JXL compression inside their DNG files when performing a photomerge in Ligthtroom based on the logic of space savingings in linear DNG files.

@euzada
Copy link
euzada commented May 2, 2024

I was going to suggested this idea as I used Tiff with JPEG all the time. I just was doing some testing and still found JXL format slower than libjpeg-turbo in writing. Another limitation I am seeing, is that even if jxl claimed to be larger than jpeg, I can't write an image larger than 10kx10k pixel successfully, while in jpeg, I can write 65kx65k with no issue. The file size will be huge but I can do it. In JXL, The writing above 10k, will finish by crashing and saying jxlsave not found. It can't handle larger files.
Does anyone else notice the same?

@AngelaDMerkel
Copy link
AngelaDMerkel commented May 3, 2024

Does anyone else notice the same?

It depends on which version of cjxl jxlsave is using. The JXL team recent changed the encoder and significantly improved memory performance. I have found that the encoder is extremely memory hungry and often crashes if your system isn't capable. I have never tried to compress a gigapixel image though.

That said, JXL has a lossless mode which is where I see myself using this feature. I have a lot TIFF containers with special metadata or layers and being able to losslessly compress in 32/16bit is something JPEG cannot do. JXL is also better for some kinds of scientific data as it can contain far more channels including non-visible and (obviously) alpha.

@jcupitt
Copy link
Member Author
jcupitt commented May 3, 2024

There's a TIFF tag for JXL compression:

$ grep -i jxl *.h
tiff.h:#define COMPRESSION_JXL 50002              /* JPEGXL: WARNING not registered in Adobe-maintained registry */

So I suppose we'd just need to compress each tile with libjxl, rather like jp2k.

You can see the compression enum here:

https://github.com/libvips/libvips/blob/master/libvips/foreign/vips2tiff.c#L294-L299

So we'd need to add COMPRESSION_JXL and then fill out the various switches. We'd need to add a tile saver to jxlsave.c too. Here's the jp2k one:

https://github.com/libvips/libvips/blob/master/libvips/foreign/jp2ksave.c#L1191-L1420

So perhaps another 300 lines there. I'd guess 2 or 3 day's work, plus the same for jxlload, so perhaps a week's effort, all told.

@AngelaDMerkel
Copy link

@jcupitt Do you plan to include this as part of your fulfilment of the NGI Zero grant?

@jcupitt
Copy link
Member Author
jcupitt commented Aug 23, 2024

No, I'll be looking at HDR and streamed encode and decode under the NGI grant.

@euzada
Copy link
euzada commented Nov 19, 2024

Hi @jcupitt , any news about this enhancement? Thank you.

@AngelaDMerkel
Copy link

@jcupitt I would also be curious to know if there are plans to add support

@jcupitt
Copy link
Member Author
jcupitt commented Jan 27, 2025

I've no immediate plans. I'm finishing nip4 right now, then a conference, then some work on DICOM, then the next libvips, and then the NGI grant, I think. Maybe after that?

I'd be happy to help anyone else who wanted to add this feature, of course.

@AngelaDMerkel
Copy link

@jcupitt Thank you for the transparency and for all your time. If this were within my skill set I would absolutely make a pull request, but it's much beyond me

@jcupitt
Copy link
Member Author
jcupitt commented Jan 28, 2025
< 7AD8 /h3>

Ah, no problem, it's just a question of scheduling. Too much to do, too little time, etc.

Plus I'm a little unsure how useful it'd be. I don't know of any other software that supports JXL-in-tiled-TIFF yet.

@AngelaDMerkel
Copy link

Vips would be the first open source project to support it (that I know), but I've read a few posts by people making use of JXL in tiff and their workflows might be simplified. Adobe's DNG uses it and that's more or less TIFF, anyways.

It is niche, though, and I understand why it's not a priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0