Skip to content

Add DynamicImage::thumbnail_to_fill - #3110

Open
cv1d wants to merge 3 commits into
image-rs:mainfrom
cv1d:feature/thumbnail-to-fill
Open

cv1d wants to merge 3 commits into
image-rs:mainfrom
cv1d:feature/thumbnail-to-fill

Conversation

@cv1d

@cv1d cv1d commented Sep 13, 2026 •

Copy link
Copy Markdown

Implements feature request #3109 that matches DynamicImage::resize_to_fill with DynamicImage::thumbnail_to_fill.

@mstoeckl mstoeckl left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change looks mechanically OK (I've tested it by temporarily modifying examples/scaledown/main.rs) and I think the API is reasonable and useful.

I should warn that the new function replicates two existing issues of resize_to_fill :

  1. the intermediate image dimensions (width2, height2) may exceed the original file size (A 1x1048576 image thumbnailed to 64x64 produces (width2, height2) = (64,67108864; see #3083.)
  2. Having separate scale and crop steps will fail to center images exactly. For example, scaling when scaling a 500x400 image down to 4x4 pixels, the thumbnail may either show the left 400x400 block or the right 400x400 block.

If either is fixed, applying the fixes to both resize_to_fill and thumbnail_to_fill may be easy. (But cleanly fixing both likely requires implementing a single step "scale+crop" primitive, which may take a bit of work.)

This branch has not been deployed

No deployments
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.

3 participants