reduce the image size of picked image in swift code example
Example 1: increase the size of the image in Swiftui
struct ResizedImage: View {
var body: some View {
Image("myImage")
.resizable()
.scaledToFit()
.frame(width: 200.0,height:200)
}
}
Example 2: swift set image size
extension UIImage {
func imageResize (sizeChange:CGSize)-> UIImage{
let hasAlpha = true
let scale: CGFloat = 0.0
UIGraphicsBeginImageContextWithOptions(sizeChange, !hasAlpha, scale)
self.draw(in: CGRect(origin: CGPoint.zero, size: sizeChange))
let scaledImage = UIGraphicsGetImageFromCurrentImageContext()
return scaledImage!
}
}