Skip to content
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

add JPEG XL support via pillow-jpegxl-plugin #344

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

BPplays
Copy link

@BPplays BPplays commented Aug 9, 2024

this PR adds JPEG XL support via a pillow plugin pillow-jpegxl-plugin.
I've tested on JPEG XL images made with libjxl cjxl and it seems to work fine



this closes #333

@CyanVoxel CyanVoxel added Type: Enhancement New feature or request Type: UI/UX User interface and/or user experience Status: Review Needed A review of this is needed labels Aug 9, 2024
@CyanVoxel CyanVoxel added this to the Alpha 9.4 milestone Aug 9, 2024
@CyanVoxel CyanVoxel self-assigned this Aug 21, 2024
@CyanVoxel CyanVoxel modified the milestones: Alpha 9.4, Alpha 9.5 Aug 23, 2024
Copy link
Collaborator

@eivl eivl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont know the image format, but the implementation looks correct.
Just keep in mind that pillow plugins and pillow itself needs to be lifted to newer versions when 3.13 support is in the works.

@EugeneVert
Copy link

EugeneVert commented Aug 31, 2024

Just as a note, jxlpy may be a better choice, as it uses direct bindings to libjxl and has an MIT license. At the same time, the pillow-jpegxl-plugin seems to be doing a python->rust->libjxl binding through jpegxl-rs, which has GPL-3.0 license.
But keeping in mind that TagStudio itself has a GPL-3.0 licence, both jxlpy and pillow-jpegxl-plugin both seem to be suitable

@BPplays
Copy link
Author

BPplays commented Aug 31, 2024

@EugeneVert i went with pillow-jpegxl-plugin because jxlpy claims: 'This project is still in alpha stages and needs testing. It may contain bugs!'. and it says support status for the pillow plugin is 'Partial' so i don't know how well it works

@CyanVoxel
Copy link
Member

From what I understand, pillow-jpegxl-plugin presents itself as having an MIT license despite using bindings from jpegxl-rs which is under GPL-3: meaning that (as far as I understand license-wise) that pillow-jpegxl-plugin can't really be distributed under MIT.

Furthermore, jxlpy which also presents itself as MIT and uses bindings from libjxl which in turn is licensed under BSD-3: an equally incompatible license with MIT.

What does this mean for this project though? Well since TagStudio uses GPL-3, it's compatible with GPL-3 and BSD-3 regardless. It's just worth it to note that these libraries may update their licenses at some point to comply with the libraries they use, and that neither may truly be "MIT".

@CyanVoxel CyanVoxel added the Priority: Medium An issue that shouldn't be be saved for last label Sep 1, 2024
@CyanVoxel
Copy link
Member

Unfortunately I'm having trouble sourcing jxl files to test, and can't verify that they're appearing how they should. Since chrome-based browsers don't support jxl and most if not all of my image viewing and editing software has limited support if any at all, I can't tell if any of these files are appearing as they're intended to. I've found a discrepancy in one of them but I don't know if it's an error on the side of my image viewer or on the PIL plugin (or both). If you have some jxl files along with a reference overview of how they're supposed to appear, that would be greatly appreciated.
image

@BPplays
Copy link
Author

BPplays commented Sep 2, 2024

@CyanVoxel
here is a zip with some images inside: jxl, webp, and png of the same image
https://github.com/BPplays/images/raw/main/issues/jxl_ts/jxldem/👍.zip

there are also jpeg xls on https://jpegxl.info/test-page/.
floorp browser and qview support them out of the box pretty well, floorp seems to have fixed the issues with firefox's experimental support.

also can you send me the image you found a discrepancy in with to test it.

@floogulinc
Copy link
Contributor

The author of jxlpy has a PR adding JPEG-XL support to Pillow itself that hopefully will be merged at some point. We're waiting for that for hydrus as at least last time I tried using either of these plugins they weren't really working, though perhaps that has changed seeing as it seems to be working somewhat here.

python-pillow/Pillow#7848

@BPplays
Copy link
Author

BPplays commented Sep 6, 2024

@floogulinc the plugin i used for this PR seems to work fine with images i converted using cjxl from libjxl,
i wanted to use a plugin instead of waiting for python-pillow/Pillow/pull/7848 because the PR doesn't seem very active

@CyanVoxel CyanVoxel removed the Status: Review Needed A review of this is needed label Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium An issue that shouldn't be be saved for last Type: Enhancement New feature or request Type: UI/UX User interface and/or user experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: jpeg xl support
5 participants