Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more flexible target size options to ImageRequest.ThumbnailOptions #677

Merged
merged 8 commits into from
Feb 26, 2023

Conversation

kean
Copy link
Owner

@kean kean commented Feb 26, 2023

In the previous version, the only available option was maxPixelSize:

// Before
ImageRequest.ThumbnailOptions(maxPixelSize: 64)

The main issue with maxPixelSize is that it creates a thumbnail that fits the target size. For example, if you have a wide image with 2000x400 pixel size and resize it to maxPixelSize: 40, the thumbnail will have the size 40x8 pixels. There was no way to create a 200x40 thumbnail, which is what you typically want to make sure the images have enough pixels to look good.

In addition to init(maxPixelSize:), there is now a new initializer with the parameters that directly match ImageProcessors.Resize, so it's easy to switch between them.

// After
ImageRequest.ThumbnailOptions(size: CGSize(width: 64, height: 64), contentMode: .aspectFill)

// Produces the same result as the following processor
ImageProcessors.Resize(size: CGSize(width: 64, height: 64), contentMode: .aspectFill)

The default contentMode is .aspectFill – the same as for ImageProcessors.Resize. And the default target size unit is .points.

@kean kean changed the base branch from main to nuke-12 February 26, 2023 15:56
@kean kean merged commit 5caa626 into nuke-12 Feb 26, 2023
@kean kean deleted the thumbnail-options branch February 26, 2023 17:10
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.

None yet

1 participant