Repository navigation
[V4] Select the JPEG decode scale from the fitted target size - #3270
Merged
Merged
Conversation
JPEG decoder - The decoder fits the source into TargetSize with ResizeMode.Max, as ScaleToTargetSize does. Before, it compared the block scales with the full target box, so the selected scale depended on the aspect ratio. - In Combined mode a resize follows the scaled decode. The scaled image keeps at least two times the fitted size, because a block scale is a box filter inside each 8x8 block. libvips uses the same rule. - In IdctOnly mode the scaled decode is the output. The decoder selects the smallest block scale that covers the fitted size. Tests - New scale cases for the factor of two and for a fitted target. - The four Calliphora resize references are updated. 101 x 150 is the ResizeMode.Max size of 804 x 1198 in 150 x 150. The old references were 100 x 150 because Round(100.5) of the 201 x 300 decode gave 100.
This was referenced Nov 24, 2026
IhateTrains
pushed a commit
to ParadoxGameConverters/ImperatorToCK3
that referenced
this pull request
Nov 25, 2026
Updated [SixLabors.ImageSharp](https://github.com/SixLabors/ImageSharp) from 4.1.3 to 4.1.4. <details> <summary>Release notes</summary> _Sourced from [SixLabors.ImageSharp's releases](https://github.com/SixLabors/ImageSharp/releases)._ ## 4.1.4 ## What's Changed * Add missing Bgra32 constructors by @JimBobSquarePants in SixLabors/ImageSharp#3248 * [V4] Correct adaptive threshold windows for narrow regions and borders by @JimBobSquarePants in SixLabors/ImageSharp#3249 * [V4] Fix buffered encoder overwrites and forward seeks by @JimBobSquarePants in SixLabors/ImageSharp#3250 * [V4] Fix PNG empty chunks, palette bounds and transparency byte order by @JimBobSquarePants in SixLabors/ImageSharp#3251 * [V4] Validate BMP headers before allocating pixel storage by @JimBobSquarePants in SixLabors/ImageSharp#3252 * [V4] Fix GIF LZW table bounds and frame clipping by @JimBobSquarePants in SixLabors/ImageSharp#3253 * [V4] Apply TIFF sample-depth defaults without changing invalid layouts by @JimBobSquarePants in SixLabors/ImageSharp#3254 * [V4] Decode TIFF large strips and backwards directory chains by @JimBobSquarePants in SixLabors/ImageSharp#3255 * [V4] Fix WebP container boundaries and odd-length metadata by @JimBobSquarePants in SixLabors/ImageSharp#3256 * [V4] Apply luma AC sharpening in the SIMD WebP quantizer by @JimBobSquarePants in SixLabors/ImageSharp#3257 * [V4] Recover JPEG restart markers through the shared reader by @JimBobSquarePants in SixLabors/ImageSharp#3258 * [V4] Preserve UTF-8 declarations in cloned IPTC profiles by @JimBobSquarePants in SixLabors/ImageSharp#3259 * [V4] Preserve PGM and PPM sample precision by @JimBobSquarePants in SixLabors/ImageSharp#3260 * [V4] Validate sRGB transfer curves before skipping ICC conversion by @JimBobSquarePants in SixLabors/ImageSharp#3262 * [V4] Correct sampled sRGB detection and use bulk curve validation by @JimBobSquarePants in SixLabors/ImageSharp#3263 * Backport EXR, decoder resize, and allocator fixes to v4 by @JimBobSquarePants in SixLabors/ImageSharp#3267 * Backport decoder configuration and Mono WASM AOT fixes to v4 by @JimBobSquarePants in SixLabors/ImageSharp#3268 * [V4] Select the JPEG decode scale from the fitted target size by @JimBobSquarePants in SixLabors/ImageSharp#3270 * [V4] Keep decoded palette colors exact when encoding by @JimBobSquarePants in SixLabors/ImageSharp#3274 * [V4] Clear BMP row padding and write ANI bitmap frames as CUR frames by @JimBobSquarePants in SixLabors/ImageSharp#3278 * [V4] Dispose PNG chunk buffer if TryReadChunk throws after allocation by @JimBobSquarePants in SixLabors/ImageSharp#3281 * [V4] Check the BMP, ICO and CUR color table size before allocation by @JimBobSquarePants in GHSA-728h-j83x-rx28 * [V4] Decode TIFF JPEG strips only with the JPEG decoder by @JimBobSquarePants in GHSA-hh64-22wf-5398 * [V4] Stop the EXR RLE and B44 decoders returning uninitialized memory by @JimBobSquarePants in GHSA-rqf5-2vx8-xhrm * [V4] Check the TIFF tile buffer size for fax decoding by @JimBobSquarePants in GHSA-29m3-m8cq-vcwf * [V4] Limit PNG legacy EXIF and IPTC profile parsing by @JimBobSquarePants in GHSA-44ch-5xxf-8g8f * [V4] Fix a 1-byte over-read in PNG interlaced decoding below 8 bits per pixel by @JimBobSquarePants in SixLabors/ImageSharp@e995f21 **Full Changelog**: SixLabors/ImageSharp@v4.1.3...v4.1.4 Commits viewable in [compare view](SixLabors/ImageSharp@v4.1.3...v4.1.4). </details> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.
Prerequisites
Description
This PR backports commit 89b7df5 from #3269 to
release/4.1.x.JPEG decoder
TargetSizewithResizeMode.Max, asScaleToTargetSizedoes. Before, it compared the block scales with the full target box. Thus, the selected scale depended on the aspect ratio of the target.Combinedmode, a resize follows the scaled decode. The scaled image keeps at least two times the fitted size, because a block scale is a box filter inside each 8x8 block. libvips uses the same rule.IdctOnlymode, the scaled decode is the output. The decoder selects the smallest block scale that covers the fitted size.Tests
ResizeMode.Maxsize of 804 x 1198 in 150 x 150. The old references were 100 x 150, becauseRound(100.5)of the 201 x 300 decode gave 100.