Repository navigation
Add optional jxl extra for JPEG XL page support - #290
Merged
Merged
Conversation
Pillow has no JPEG XL decoder, so comics with .jxl pages could not be cover-hashed ("Unable to get cover hash.") or checked for duplicate pages.
Add pillow-jxl-plugin as an optional `jxl` extra and register it with Pillow on package import when it's installed. Document the extra in the README and add a cover-hash test that's skipped unless the plugin is installed.
pillow-jxl-plugin raises RuntimeError (not OSError) on corrupt or truncated JXL data. That error escaped get_comic_cover_hashes_cached and could abort a tagging run. In duplicate detection it was logged with a full stack trace instead of the usual debug skip. - Catch RuntimeError when hashing covers (talker.py) and pages (duplicates.py). - Add tests for a truncated JXL image and for a simulated decoder RuntimeError, in both modules. - Install the jxl extra in CI on Python 3.11-3.13, the only versions pillow-jxl-plugin ships wheels for, so the JXL tests actually run.
pillow-jxl-plugin defaults to DECODE_THREADS = -1, which starts one decoder thread per CPU core for every image. Duplicate detection already decodes pages in a thread pool, so this oversubscribed the CPU. Set DECODE_THREADS = 0 after registering the plugin.
pillow-jxl-plugin decodes the whole image inside Image.open() and has no option to decode at a smaller size, so the img.draft() call in duplicate detection doesn't help with JXL pages. Note the extra CPU/memory cost in the README's jxl extra entry, point users to --quick-duplicates, and update the comment above the draft() call.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pillow can't decode JPEG XL images, so comics with
.jxlpages couldn't be cover-hashed. They printed "Unable to get cover hash." and couldn't be matched by cover, and duplicate-page detection didn't work on them either.This PR adds
pillow-jxl-pluginas an optionaljxlextra. When the plugin is installed, it's registered with Pillow on package import, so cover matching (talker.py) and duplicate detection (duplicates.py) both handle.jxlpages.Changes
pyproject.toml/uv.lock: newjxl = ["pillow-jxl-plugin>=1.3.8"]extrametrontagger/__init__.py: importpillow_jxlif it's installed; skip it silently if notREADME.md: document thejxlextratests/test_talker.py: cover-hash test for a JXL cover, skipped when the plugin isn't installedWithout the extra, behaviour is unchanged.