Skip to content

feat(image): choose the resampling filter for resizes (#1601) - #1978

Merged
KnifeLemon merged 3 commits into
KnifeLemon:mainfrom
cre8ive-marketing:feature/1601-resize-filter
Dec 2, 2026
Merged

KnifeLemon merged 3 commits into
KnifeLemon:mainfrom
cre8ive-marketing:feature/1601-resize-filter

Conversation

@cre8ive-marketing

Copy link
Copy Markdown
Collaborator

Closes #1601

What changes

  • New field: ImageOptions.ResizeFilter (Auto, Lanczos, Mitchell, CatmullRom, Bilinear, Box, Nearest). The default is Auto.
  • Where it's set: a Resampling box under Resize in the preset editor. It's shown when Resize isn't "Original size".
  • One helper: ImageEncoder.ApplyOptions sets image.FilterType once, before it resizes anything. Every later resize of that image uses it:
    • Percent, LongEdge, Width, Custom and MinShortEdge;
    • the format caps in FitFormat;
    • ICO and CUR (256 px);
    • the copies the file-size fit scales down (Clone keeps the filter).
  • Format caps: they follow the user's choice, not Auto.
  • Auto: FilterType stays unset, so ImageMagick chooses as before (Mitchell when enlarging or with alpha or a palette, Lanczos when shrinking).

Filter names

Option ImageMagick
Catmull-Rom (bicubic) Catrom
Bilinear Triangle
Box Box
Nearest neighbour Point
  • No "Bicubic" entry of its own: the label "Catmull-Rom (bicubic)" covers it, and FilterType.Cubic (the soft B-spline) isn't offered.
  • Spline36: left out, since I couldn't confirm it maps to CubicSpline + filter:lobes.

Gallery

  • Allow-list: resizeFilter is in SharedPresetRules as an enum rule.
  • Versions: SharedPresetVersions.Fields has ["presets[].image.resizeFilter"] = "2.6.0".
  • No schema step.

i18n

presets.resize_filter, presets.resize_filter_hint and presets.resize_filter.{value} are in all 23 files. "Lanczos" and "Mitchell" are names and stay as they are.

Tests

  • New test: ImageFormatTests.ApplyOptions_resizes_with_the_chosen_filter enlarges a 2 × 2 checkerboard 4×.
    • Nearest stays exactly 2 colours.
    • Auto blends into greys.
  • Runs: that test, Core tests (1894 passed), and the App tests for the preset editor, localization and gallery (272 passed).

Not checked

  • The full App suite: my run hung, so I stopped it and ran the focused set above.
  • The "Edit pictures" tool's own resize (ImageEditViewModel) has no filter box yet. Say if you want it there too.

Image presets get ImageOptions.ResizeFilter (Auto, Lanczos, Mitchell,
Catmull-Rom, bilinear, box, nearest neighbour), shown under Resize in
the preset editor. ApplyOptions sets it on the image before any resize,
so the format caps, icons, cursors and the file-size fit use it too.
Auto leaves FilterType unset, as before. The gallery allow-list and
SharedPresetVersions know the field (2.6.0).

Closes KnifeLemon#1601
@github-actions github-actions Bot added the feature New features label Dec 2, 2026
@cre8ive-marketing
cre8ive-marketing marked this pull request as ready for review December 2, 2026 04:31

@KnifeLemon KnifeLemon left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cre8ive-marketing, this covers every call site from the plan (format caps, ICO/CUR, the size fit) with one helper, and the filter table in the description is very clear.

One thing to fix before merge:

  1. Lenient enum reading. ImageOptions.ResizeFilter needs [JsonConverter(typeof(LenientEnumJsonConverter<ResizeFilter>))], like the other preset enums (Rotation, Flip, FitsTiff, RasterColours…). FileeJsonContext reads enums strictly. If a later Filee adds a filter (Spline36, say), an older one would fail to read the whole presets file and reset every preset. Please add a small test like CadOptionsTests.Cad_colours_are_saved_by_name_and_read_leniently covering three cases:
    • the filter is saved by name;
    • a missing field reads as Auto;
    • an unknown name reads as Auto.

Smaller things:

  1. ko.json presets.resize_filter_hint uses 합니다체, and the app uses 해요체. Suggested: "크기를 바꿀 때 픽셀을 섞는 방식이에요. 자동은 줄일 때 Lanczos, 키울 때 Mitchell을 써요."
  2. ICNS still hard-codes FilterType.Lanczos after ApplyOptions (IcnsConverter.cs:54). So the CHANGELOG's "for icons" covers ICO/CUR but not ICNS. Either honour the choice there, or keep Lanczos and say so.
  3. The box is hidden when Resize is "Original size", but the filter still applies to the format caps, ICO/CUR and the file-size fit. A preset switched back to Original size keeps a hidden filter. Resetting it to Automatic when Resize goes to None would avoid that.

"Edit pictures" doesn't need to be in this PR. We can leave it for a follow-up if someone asks.

- ImageOptions.ResizeFilter reads leniently: a filter from a newer Filee
  (or a missing field) is Automatic instead of breaking presets.json.
  Test: saved by name, missing, unknown.
- ICNS uses the preset's filter too (Automatic stays Lanczos).
- The editor saves Automatic when Resize is Original size, so no hidden
  filter is kept.
- ko.json hint in 해요체.

@KnifeLemon KnifeLemon left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cre8ive-marketing, all addressed: the lenient enum with its test, the ko wording, ICNS and the hidden filter reset. We'll merge once CI is green.

@KnifeLemon
KnifeLemon merged commit aa5ca1a into KnifeLemon:main Dec 2, 2026
11 checks passed
@cre8ive-marketing
cre8ive-marketing deleted the feature/1601-resize-filter branch December 3, 2026 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add Advanced Resampling Methods and Precise Target File Size Compression

2 participants