dmytro-anokhin / url-image

AsyncImage before iOS 15. Lightweight, pure SwiftUI Image view, that displays an image downloaded from URL, with auxiliary views and local cache.
MIT License
1.1k stars 96 forks source link

Option to center crop images before they are returned as a view #167

Closed FloDa88 closed 2 years ago

FloDa88 commented 2 years ago

Is your feature request related to a problem? Please describe. I am having problems fitting images of different aspect ratios into a grid layout.

Describe the solution you'd like It would be great if the image could be center cropped (to a square, a rectangle with given aspect ratio) before it is returned as a view.

Describe alternatives you've considered Scaling the image with a distorted aspect ratio does not look good.

dmytro-anokhin commented 2 years ago

Hello, if I understand correctly - you can do this using SwiftUI modifiers:

image
    .resizable()
    .aspectRatio(contentMode: .fill)