Repository navigation
Accept padding that leaves one pixel of content on odd and tiny sizes [patch] - #141
matt-edmondson wants to merge 1 commit into
Conversation
… [patch] Validate compared Padding against Size / 2, which rounds an odd size down. --size 1 failed even at the default padding of 0, and --size 3 --padding 1 was refused although the pipeline's own clamp, EffectivePadding's (size - 1) / 2, allows it. Validate now rejects only Padding * 2 >= Size, the same bound. Fixes #122 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Rt1SUkG3bsTZEWbmGirSx3
|
The This failure isn't caused by this PR. The scheduled CI run on Generated by Claude Code |
Fixes #122
What changed
Arguments.Validatecompared the padding againstSize / 2, and integer division rounds an odd size down. As a result:--size 1failed with "Padding must be less than half the size" even at the default padding of 0.--size 3 --padding 1was rejected, although the pipeline's own clamp (EffectivePadding,(size - 1) / 2) allows it and leaves a 1-pixel image.Validatenow rejects onlyPadding * 2 >= Size, which is the same boundEffectivePaddinguses. The error message is unchanged: it is now exactly true ("less than half the size", with no rounding). The--paddinghelp text and the README's option and exit-code tables now state the bound aspadding * 2 < size.Tests (
ArgumentsTests)ValidateAcceptsTheSmallestSizesThePipelineHandles:Size = 1, Padding = 0andSize = 3, Padding = 1are both valid.ValidateRejectsPaddingThatLeavesNoContentOnASmallSize:Size = 4, Padding = 2is rejected with the padding message.ValidateUsesIntegerDivisionForOddSizespinned the old rounding, so it is replaced byValidateAcceptsPaddingThatLeavesOnePixelOnAnOddSize: on 33 pixels, 16 is now accepted and 17 rejected.With the
Arguments.cschange reverted, the three new cases fail. With the change, everyArgumentsTestscase passes, along with the rest of the suite exceptOutputMatchesTheGoldMaster. Those 8 cases fail identically onmainin this environment, because the checkout has the gold-master PNGs only as Git LFS pointer stubs.Note on CI
The scheduled CI run on
mainis red as well (run 37857512628). Locally, restore onmainfails withNU1902/NU1903"Warning As Error" forSixLabors.ImageSharp3.1.12 (GHSA-j3p4-wp97-rph4 and others). The failure isn't caused by this PR, and this PR doesn't widen its scope to bump ImageSharp.🤖 Generated with Claude Code
https://claude.ai/code/session_01Rt1SUkG3bsTZEWbmGirSx3
Generated by Claude Code