fix(imagepicker): 크롭 범위를 보정한다
This commit is contained in:
15
SodaLive/Sources/ImagePicker/ImageCropGeometry.swift
Normal file
15
SodaLive/Sources/ImagePicker/ImageCropGeometry.swift
Normal file
@@ -0,0 +1,15 @@
|
||||
import CoreGraphics
|
||||
|
||||
enum ImageCropGeometry {
|
||||
static func maximumCropSize(fitting imageSize: CGSize, aspectRatio: CGFloat) -> CGSize {
|
||||
guard imageSize.width > 0, imageSize.height > 0, aspectRatio > 0 else {
|
||||
return .zero
|
||||
}
|
||||
|
||||
if imageSize.width / imageSize.height > aspectRatio {
|
||||
return CGSize(width: imageSize.height * aspectRatio, height: imageSize.height)
|
||||
}
|
||||
|
||||
return CGSize(width: imageSize.width, height: imageSize.width / aspectRatio)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user