Conversation
libjpeg's `dct_method` is read by both the compressor and the decompressor, and `cjpeg`/`djpeg` both accept `-dct`, but the setting was reachable only through `Decompress::dct_method`. `Compress` keeps `cinfo` private, so a caller that wants to pick the encoder's DCT algorithm has no way to do it. Mirrors `Decompress::dct_method` exactly, reusing the existing `DctMethod` enum, and adds a test that encodes with each of the three methods.
8 of 12 tasks
pashifika
force-pushed
the
feat/compress-dct-method
branch
from
August 30, 2026 00:56
cde150a to
77c0dd4
Compare
pashifika
added a commit
to pashifika/comic-auto-resize
that referenced
this pull request
Aug 30, 2026
The fork's two commits were authored under the wrong Git identity: the scratch clone carried no repository-local `user.name`/`user.email` and fell back to this machine's global configuration, which is not the identity this project's OSS contributions belong under. Both fork branches were rewritten with the correct identity and force-pushed. The content is unchanged — `git diff` against the previous heads is empty — so this is an attribution fix, not a code change. - `[patch.crates-io]` rev is now 58f4e0ef91f2a0c477140734ef8b3fe5403befc3 - The upstream pull request's head is now 77c0dd48bcba2d8ba97c823edfea6eadaf8673ea Refs: ImageOptim/mozjpeg-rust#54
This was referenced Aug 30, 2026
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
Adds
Compress::set_dct_method, mirroring the existingDecompress::dct_method.libjpeg's
dct_methodfield is read by both the compressor and the decompressor, andcjpeg/djpegboth accept-dct islow|ifast|float. In this crate only the decompressionside is reachable:
Compresskeepscinfoprivate and exposes no setter, so a caller thatwants to choose the encoder's DCT algorithm has no way to do it and silently gets the
library default.
Motivation
I am porting a JPEG recompression tool from Go to Rust. Its CLI has always exposed
--dct float|ifast|islowas the encoder DCT/IDCT method — the Go binding it used appliedthe setting to both sides — so reproducing the flag needs this setter. Without it the flag
would have to be documented as decoder-only or dropped.
Changes
src/compress.rs:Compress::set_dct_method(&mut self, method: DctMethod), reusing theDctMethodenum already re-exported fromlib.rs, so no new public type is introduced.produces output with an SOI marker.
Notes
unsafeadded: the method writes a plain field oncinfo, exactly asDecompress::dct_methoddoes.Compressconvention (set_*) rather thanDecompress's baredct_method.cargo testpasses locally onaarch64-apple-darwin(18 lib tests, plus the integrationand doc test targets).