Add AVIF and JPEG XL image format support #498
Closed
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.
Add AVIF and JPEG XL Image Format Support
Summary
This PR adds native support for AVIF and JPEG XL (JXL) image formats to YACReader, enabling users to read comic books containing these modern, efficient image formats.
Motivation
AVIF and JPEG XL are modern image formats that offer:
Currently, YACReader only supports traditional formats (JPEG, PNG, WebP). Users with comics containing AVIF or JXL images cannot view them, even though these formats are becoming more common.
Changes
Core Implementation
New decoder module (
common/image_decoders.{cpp,h}):isAvif()/isJxl(): Format detection via magic byte checkingdecodeAvif(): AVIF decoding using libavif 1.0.4+decodeJxl(): JXL decoding using libjxl 0.7+ with multi-threaded parallel runnerUnified image loading:
loadImageFromData()helper incover_utils.cppinitial_comic_info_extractor.cpp)Format registration:
comic.cppto recognize*.avifand*.jxlfile extensionsBuild System
Library linking:
YACReaderLibrary.proandYACReaderLibraryServer.proDocker improvements:
libavif-devandlibjxl-devto build dependencieslibavif16andlibjxl0.7to runtime imagesevenzip-builderfor better cachingTesting
tests/image_format_test/):sample.avif(470KB),sample.jxl(180KB) embedded as Qt resourcesTechnical Details
Format Detection
AVIF: Checks for ISO Base Media File Format (ISOBMFF) with
ftypbox containing "avif" brand:JXL: Supports both formats:
FF 0Amagic bytes (naked codestream)JXL(with space) at offset 4 (ISOBMFF container)Decoding Pipeline
Thread Safety
JxlResizableParallelRunnerfor optimal performanceCompatibility
Backwards Compatibility
✅ Fully backwards compatible
Platform Support
Client Compatibility
Testing & Verification
Test Suite
The PR includes comprehensive automated tests in
tests/image_format_test/:Prerequisites
Local Build & Test
Manual Testing with Sample Comics
Docker Testing
Verified Testing Results
✅ Library Scanning: Successfully processed AVIF/JXL comics
✅ Cover Extraction: All formats extracted and displayed
✅ Server Testing: YACReaderLibraryServer verified
✅ iOS Client Verification
Performance
Decode Times (sample 2048x2048 image)
Memory Usage
Dependencies
New Runtime Dependencies
Existing Dependencies (unchanged)
Screenshots
Note: Sample images included in tests/image_format_test/ can be used to verify rendering
Checklist
References
Review Notes: This PR introduces two new image format codecs with comprehensive testing. The implementation is isolated in a new module (
image_decoders.{cpp,h}) to minimize impact on existing code. All changes are additive - no existing functionality is modified or removed.