resizing UIImage the fastest and efficient way

In a performance sample of Image Resizing Techniques the score was

  • 0.1420 UIKit
  • 0.1722 Core Graphics
  • 0.1616 Image I/O
  • 2.4983 Core Image
  • 2.3126 vImage

so the fastest and simplest way is:


let renderer = UIGraphicsImageRenderer(size: size)
let resized = renderer.image { (context) in
    image.draw(in: CGRect(origin: .zero, size: size))
}

Resize a UIImage the right way is from 2009 but contains useful talk about interpolation quality and preserving the aspect ratio.