Repository navigation
add flat quantization tables to JPEG encoding - #87
Merged
Merged
Conversation
Closed
Contributor
Test coverageCompared with master where the branch left it (07793ce).
Changed
|
matmen
marked this pull request as ready for review
November 29, 2026 17:02
matmen
force-pushed
the
jpeg-flat-tables
branch
from
November 29, 2026 20:10
08dcfc7 to
6ee1bf4
Compare
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.
Adds
encodeJPEG({ quantization: 'flat' }): the same quantization step for every frequency instead of the JPEG standard's tables. Edges and text come out clearer with fewer visible artifacts.Refs #85.
'standard'by default, so existing files stay byte for byte the same. The samequalitymakes a larger file with'flat', so lower it until the size matches (by about 15 to 25 around quality 60 for photos); qualities 96 to 100 give the same file. The gain map isn't affected. The table is mozjpeg's flat one (all 16, scaled by the quality like the standard's).Measured with mozjpeg's
cjpeg(no trellis) on a photo, a 2400×1600 photo and a screenshot at qualities 60, 80 and 92: at the same PSNR the files are 13% smaller on average (from 3% to 30%), at the same SSIM 9% (from 21% smaller to 15% larger, the photo at quality 60 is larger). I looked at crops at the same file size and found edges clearer and fewer artifacts.Checked:
cjpeg -qtables(libjpeg-turbo 2.1.5) with sixteens gives identical files for 432 cases;tests/jpeg-quantization.jskeeps 9 of them as hashes, checks that strokes come out with less error at the same file size, and that the option reaches transparent images and the primary image of a gain map JPEG but not the gain map.