-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add JPEG XL Open/Read support via libjxl #7848
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
base: main
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
|
May you please commit the images as LFS? |
|
Do you mean those |
|
They already setup lfs and they only use for other larger stuff. Let it stay as you did. |
Removed jxl feature
for more information, see https://pre-commit.ci
|
Mac OS builds were failing because clang complained about goto labels being declared before variables in scope. |
src/PIL/__init__.py
Outdated
| "IptcImagePlugin", | ||
| "JpegImagePlugin", | ||
| "Jpeg2KImagePlugin", | ||
| "JxlImagePlugin", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming things: like other plugins, shall we use the name of the format rather than the extension?
| "JxlImagePlugin", | |
| "JpegXlImagePlugin", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. Not sure why I decided to go with "jxl" from the beginning.
Would you want me to change all the references to jxl (including tests, function/class names, feature.jxl) or only plugin and .c extension filename?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think let's just use jxl for the filename extension (so the Tests/images/jxl/) dir is fine too) and of course the MIME type, and change the rest.
src/PIL/JxlImagePlugin.py
Outdated
| # jpeg xl does some weird shenanigans when storing exif | ||
| # it omits first 6 bytes of tiff header but adds 4 byte offset instead | ||
| if len(exif) <= 4: | ||
| return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test case for this and _getexif?
|
I've merged in And this is failing to build for me with: Full log: log2.txt |
Thanks for reporting. The |
|
@radarhere couple of questions:
|
|
|
@radarhere is there any movement on this PR? Currently a Rust version of the libjxl library is being implemented and looks like it's going to end up in Firefox, and Adobe is planning on adding support for JXL for PDFs as well (see the this interop discussion) |
|
Mostly, lack of movement is just due to not having an overabundance of time. I have asked some questions in comments here, and have asked a question about this at libjxl/libjxl#4400, but haven't received useful advice. Sooner or later, I will probably just move things along anyway though. |
95b73ff to
e41cad7
Compare
130a4f5 to
66e5838
Compare
|
|
||
| jpegxl = feature.get("jpegxl") | ||
| if isinstance(jpegxl, str): | ||
| # jxl and jxl_threads are required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have thought that jxl_threads should be an optional extra, not a requirement? If it's only purpose is to speed things up, then if a user has jxl present on their system but not jxl_threads, then that doesn't sound like we should stop them from using the jxl library.
16264dd to
4d60d9c
Compare
4d60d9c to
9096240
Compare
Not only that, Google seems now to "consider" to add JXL back to Chrome. https://groups.google.com/a/chromium.org/g/blink-dev/c/WjCKcBw219k/m/NmOyvMCCBAAJ They will add it, they just try to save face right now by talking nonsense about now seeing "developer signals". |
42a1b66 to
285c9ad
Compare
d39ea8d to
6219234
Compare
6219234 to
0503c3d
Compare

Helps #4247
This PR enables opening and reading JPEG XL images and animations.
Supported image modes are: RGB, RGBA, RGBa, L, LA, La.
A relatively recent libjxl version is needed to compile Pillow with libjxl support.
The main changes are the addition of
_jxl.candJxlImagePlugin.py.I'm also the author of jxlpy so this PR was influenced by the work of contributors there. This PR is also largely based on
WebPImagePlugin.pywhich had similar implementation.Why?
JPEG XL has recently seen increased adoption especially in Apple ecosystem. A lot of users are requesting Pillow support for JPEG XL as their products use Pillow and need to be able to handle
jxlfiles.I'm open to suggestions and comments. I understand such change would need a lot of testing and probably changes. After all Pillow would need to become somewhat dependent on libjxl. Creating documentation will not be a big problem however I decided to wait for feedback from Pillow core developers.