This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func resizeImage(image: UIImage, newSize: CGSize) -> UIImage { | |
let imageSize = image.size | |
let width = imageSize.width | |
let height = imageSize.height | |
let widthFactor = newSize.width/width | |
let heightFactor = newSize.height/height | |
let scaledFactor = (widthFactor < heightFactor) ? widthFactor : heightFactor | |
let scaledWidth = width * scaledFactor |