I want to use the function CGImageSourceCreateThumbnailAtIndex to create a thumbnail from an UIImage. All I have is the UIImage itself. Th
Swift 4 code
let imageData = UIImagePNGRepresentation(image)!
let options = [
kCGImageSourceCreateThumbnailWithTransform: true,
kCGImageSourceCreateThumbnailFromImageAlways: true,
kCGImageSourceThumbnailMaxPixelSize: 300] as CFDictionary
let source = CGImageSourceCreateWithData(imageData, nil)!
let imageReference = CGImageSourceCreateThumbnailAtIndex(source, 0, options)!
let thumbnail = UIImage(cgImage: imageReference)