RawTherapee icon indicating copy to clipboard operation
RawTherapee copied to clipboard

Add ability to import JXL images

Open xiota opened this issue 2 years ago • 48 comments

This allows RawTherapee to import JXL images. Addresses [the import portion] of #6273.

xiota avatar Sep 22 '21 08:09 xiota

@xiota Thanks for this!

Addresses half of #6273.

Which half? And can you elaborate a bit about what is still missing?

Thanatomanic avatar Sep 22 '21 08:09 Thanatomanic

@xiota Thanks for your contribution! :+1: There seem to be some (error) conditions under which ImageIO::loadJxl() leaks allocated memory in buffer. Could you double-check?

Floessie avatar Sep 22 '21 11:09 Floessie

@Floessie Thanks for letting me know. I added a couple lines to free the buffer.

xiota avatar Sep 22 '21 15:09 xiota

@xiota Just out of curiosity, do you have a particular reason to force-push the last few commits instead of committing regularly with descriptions? We can squash-merge things in the end so the master commit log won't be polluted.

Thanatomanic avatar Sep 22 '21 16:09 Thanatomanic

@Thanatomanic Was just to keep the commit log clean. Didn't know you would squash merge.

xiota avatar Sep 22 '21 17:09 xiota

This was working yesterday, but it isn't working after I recompiled today without making any changes.

xiota avatar Sep 22 '21 21:09 xiota

It's working again. I was trying to make compiling with libjxl optional, but something was being cached, so it looked like it was working when it wasn't. Someone else will have to make the changes needed to make cmake detect and load libjxl as needed. (Right now it's required.)

xiota avatar Sep 23 '21 21:09 xiota

One of the disabled extensions is png. Why is that?

There was a time, where some png files led to crashes of RT when starting RT on a folder which such a file. I think we can enable png per default now. Iirc the crashes should be fixed...

heckflosse avatar Oct 24 '21 12:10 heckflosse

I remember now. It was issue #3794 right? There was also a question about it in #4915.

Lawrence37 avatar Oct 24 '21 18:10 Lawrence37

Should I reenable PNG in this PR? Also, any advice/help for conditional compilation?

xiota avatar Oct 24 '21 19:10 xiota

I think we can enable png per default now.

Yes, but not in this PR imo (keep it cleanly focused on JXL).

Someone else will have to make the changes needed to make cmake detect and load libjxl as needed. (Right now it's required.)

@xiota Well, this is an issue indeed. I found out that on Windows MSYS2 does not provide the libjxl package yet. So anyone on Windows should first manually compile libjxl or we should start working with submodules or something. Not very convenient. My suggestion is to create a build option WITH_JXL here https://github.com/Beep6581/RawTherapee/blob/0e122a485a2339bf2331a7c54a2f5cb2ee2f2dd3/CMakeLists.txt#L197-L225 and set it to OFF by default. Then you should be able to conditionally check for the package, like here https://github.com/Beep6581/RawTherapee/blob/0e122a485a2339bf2331a7c54a2f5cb2ee2f2dd3/CMakeLists.txt#L496-L498

But I'm not at all familiar with the intricacies of CMake, so perhaps this doesn't work at all...

Thanatomanic avatar Dec 16 '21 06:12 Thanatomanic

Thanks for this effort! I would love to have JPEG XL import support in RawTherapee, what's needed to move this PR forward?

EwoutH avatar Nov 30 '22 20:11 EwoutH

Builds fine in Manjaro against libjxl-0.7.0 and libjxl_threads-0.7.0, and opens a sample .jxl file fine, though without any metadata.

Beep6581 avatar Dec 18 '22 01:12 Beep6581

though without any metadata

Is it to be expected that once we support evix2 this automagically works for jxl too?

Thanatomanic avatar Dec 18 '22 08:12 Thanatomanic

Is it to be expected that once we support evix2 this automagically works for jxl too?

If exiv2 is built w/ BMFF support, then yes.

kmilos avatar Jan 26 '23 14:01 kmilos

Converting this to a draft because the GitHub Actions workflows still need to be updated to use the JXL library. Making JXL optional may also be necessary for the moment.

Lawrence37 avatar Mar 11 '23 03:03 Lawrence37

Moving to 6.0 due to lack of activity.

Beep6581 avatar Sep 05 '23 22:09 Beep6581

@xiota Would you be able to further work on this? If so, is there anything you need to move this forward?

EwoutH avatar Sep 26 '23 12:09 EwoutH

Issues I think holding this back:

  • [x] Conditional compilation to build libjxl support only when the library is present.
  • [x] Windows library availability?
  • [ ] I'd need a refresher on how rawtherapee works
  • [ ] I'd need a refresher on how libjxl works
  • [x] update and rebase to current rawtherapee
  • [x] update for current libjxl
  • [ ] I don't understand how libjxl color management works

xiota avatar Oct 01 '23 08:10 xiota

Windows library availability?

No problem w/ this one: https://packages.msys2.org/base/mingw-w64-libjxl

I don't understand how libjxl color management works

You are not alone on that one 😉

kmilos avatar Oct 02 '23 10:10 kmilos

I force pushed to rebase to the current dev branch. It's updated to the current libjxl API (only one function changed). I also figured out how to make libjxl optional, so if it's not installed, compilation should continue with jpeg xl disabled.

xiota avatar Apr 10 '24 13:04 xiota

@Lawrence37 Would you mind running this through workflows to check that the cmake files are compatible?

I updated them to add a tristate option WITH_JXL. Default is AUTO, which enables JXL import when libjxl is available. YES force enables the feature, showing error when libjxl is not available. NO force disables the feature, even when libjxl is found.

I looked at the workflow files, and it seems for Ubuntu and MSYS, libjxl can be added to the depends lists. However, Ubuntu has libjxl-dev 0.7.0, while MSYS has libjxl 0.10.2. When I rebased, I updated and test built with 0.10.2.

xiota avatar Apr 11 '24 15:04 xiota

The workflows will probably not support jxl without installing libjxl, but I'll run them anyway.

Lawrence37 avatar Apr 12 '24 05:04 Lawrence37

@Lawrence37 Thanks for running the workflows earlier. They all passed (deps not installed and build completed with jxl export disabled).

Would you mind running the workflows again? I added libjxl to the dep lists. Hoping they'll build with jxl export enabled.

xiota avatar Apr 12 '24 22:04 xiota

Looks like... macOS and Windows workflows succeeded. I suppose people using those OSes can grab the artifacts to test?

The Linux workflows failed because they're running on Ubuntu 20.04 and 22.04, but libjxl was added in 23.04. Should be available in 24.04 in a few weeks.

How would RT devs like to proceed?

xiota avatar Apr 13 '24 05:04 xiota

It seems like there is a deb package for Ubuntu 20.04 (https://github.com/libjxl/libjxl/releases/tag/v0.10.2). We can use that or compile libjxl in the AppImage workflow. Note that the runner must be the oldest LTS Ubuntu available (currently 20.04) to maximize compatibility of the AppImage.

Lawrence37 avatar Apr 13 '24 05:04 Lawrence37

Is figuring out the deps in the workflows important for this PR or could it be deferred?

Conditional compilation seems to be working, so the deps could be left out of the Linux workflows until someone who knows how can update them.

xiota avatar Apr 13 '24 05:04 xiota

The AppImage workflow generates the official AppImage for releases, so it is important that libjxl is included. Otherwise, there will be no jxl support for AppImage users.

Lawrence37 avatar Apr 13 '24 21:04 Lawrence37

I found the button to run workflows and got the AppImage workflow to complete successfully. The resulting appimage was able to thumbnail and load a jxl file.

It uses debs from the libjxl github repo, but libhwy is from a PPA. The highway repo doesn't publish debs, and the 22.04 deb won't install on 20.04. The debian highway package has the same problem.

I'm unable to test the codeql workflow. Assuming no mistakes, it should also work. It uses libjxl from github, and libhwy from the official Ubuntu 22.04 repo.

xiota avatar Apr 14 '24 03:04 xiota

Nice! Getting a package from a PPA is less than ideal. I see highway can be installed using vcpkg install highway. vcpkg comes preinstalled in the Ubuntu 20.04 environment. I have never used vcpkg before, but it might be worth a shot.

Lawrence37 avatar Apr 14 '24 04:04 Lawrence37