Skip to content

Conversation

@lilith
Copy link

@lilith lilith commented Jan 4, 2026

Summary

set_scan_optimization_mode() and set_fastest_defaults() call jpeg_set_defaults() which resets all compression parameters, including smoothing_factor. This caused set_smoothing_factor() to have no effect if called before these methods.

Fix

Save and restore smoothing_factor around the jpeg_set_defaults() calls.

Test

Added regression test that verifies:

  1. Smoothing reduces file size for high-frequency content
  2. set_smoothing_factor() works regardless of whether it's called before or after set_scan_optimization_mode()

Fixes #45

`set_scan_optimization_mode()` and `set_fastest_defaults()` call
`jpeg_set_defaults()` which resets all compression parameters,
including `smoothing_factor`. This caused `set_smoothing_factor()`
to have no effect if called before these methods.

Fix by saving and restoring `smoothing_factor` around the
`jpeg_set_defaults()` calls.

Fixes ImageOptim#45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

set_smoothing_factor() has no effect on output

1 participant