Skip to content

Add linear color encoding for JXL save operation #2568

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

Closed
f1ac opened this issue Dec 3, 2021 · 11 comments
Closed

Add linear color encoding for JXL save operation #2568

f1ac opened this issue Dec 3, 2021 · 11 comments
Milestone

Comments

@f1ac
Copy link

f1ac commented Dec 3, 2021

Currently JxlColorEncodingSetToSRGB() is always used in jxlsave.c, but it seems calling JxlColorEncodingSetToLinearSRGB() would be more appropriate when input image has VIPS_FORMAT_FLOAT and/or VIPS_INTERPRETATION_scRGB. Currently exported linear images appear as if they have additional gamma of 2.2 applied to them because of this issue.

Libjxl tests seem to follow this logic (float input means linear output when input file has no ICC profile) at https://github.com/libjxl/libjxl/blob/main/lib/jxl/roundtrip_test.cc

@f1ac
Copy link
Author

f1ac commented Dec 3, 2021

Also it seems libjxl now has JxlEncoderSetICCProfile() method, so it can be used instead of the logic above when input files have a profile. As I can see currently ICC profiles are not handled for JXL.

@jcupitt
Copy link
Member

jcupitt commented Dec 3, 2021

Hi @f1ac,

Sure, this all sounds good. Let's tag this as an enhancement for 8.13.

@jcupitt jcupitt added this to the 8.13 milestone Dec 3, 2021
jcupitt added a commit that referenced this issue May 21, 2022
@jcupitt
Copy link
Member

jcupitt commented May 21, 2022

OK, done! I've made a PR here:

#2815

Any testing very welcome.

It looks like libjxl now has EXIF, XMP etc. as well, so we should also add support for them, and perhaps bump the minimum supprted libjxl version.

@jcupitt jcupitt closed this as completed May 21, 2022
@f1ac
Copy link
Author

f1ac commented May 21, 2022

@jcupitt Are there any nightly builds for windows? I gave up trying to compile the library, so can't test this w/o binaries unfortunately.

@jcupitt
Copy link
Member

jcupitt commented May 21, 2022

With WSL2 it should be a one-liner to build from source now:

https://github.com/libvips/build-win64-mxe

Just:

./build.sh all --nightly

To build git master libvips for windows. It does take a while :(

@jcupitt
Copy link
Member

jcupitt commented May 22, 2022

Of course, having looked at this, there's no simple way to build a specific commit. I'll try to add this feature.

@f1ac
Copy link
Author

f1ac commented May 22, 2022

I've managed to build vips master, then changed the branch in plugins/nightly/overrides.mk to "vips-all_GH_CONF := libvips/libvips/branches/add-more-libjxl-metadata". The second time it was much faster, but I guess it did not pick up the new branch as resulting JXL files are identical to the ones converted with v8.12.2. I either need to clean up build folder or the overrides do no work.

@kleisauke
Copy link
Member

If you want to test specific commits or branches, I think you also need to change nightly_version here:
https://github.com/libvips/build-win64-mxe/blob/4ddf96c4c152f129d320d27fcf11ade9f9f73e65/build/build.sh#L133
to:

nightly_version=$(wget -q -O- 'https://api.github.com/repos/libvips/libvips/git/refs/heads/add-more-libjxl-metadata' | sed -n 's#.*"sha": "\([^"]\{7\}\).*#\1#p' | head -1)

(to test the add-more-libjxl-metadata branch)

or just:

nightly_version="bb8d107445759cb5db2c15bd5ea3335905a2e817"

(to test commit bb8d107)

I'll try to add support for the --commit option tomorrow (see libvips/build-win64-mxe#44).

@jcupitt
Copy link
Member

jcupitt commented May 23, 2022

I posted a sample output image in linear space here: #2815 (comment)

There's an ICC profile too.

@f1ac
Copy link
Author

f1ac commented May 24, 2022

@jcupitt GIMP shows both jpg and jxl do not have embedded ICC, jpeg has EXIF data.

@jcupitt
Copy link
Member

jcupitt commented May 24, 2022

Sorry! I messed up. Let me try again.

jcupitt added a commit that referenced this issue May 28, 2022
* add ICC and scRGB support

see #2568

* final polish
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