Мне нужно скрыть мой UIImage до прогрессивного jpeg с помощью swift 3.0. Я нашел следующий код в стремительной 2.2:Преобразование изображения в прогрессивное JPEG в swift 3.0
let sourceImage = UIImage(named: "example.jpg")
let path = (NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString).stringByAppendingPathComponent("progressive.jpg")
let fileUrl = NSURL(fileURLWithPath: path as String, isDirectory: true)
let url = CFURLCreateWithString(kCFAllocatorDefault,fileUrl.absoluteString as CFString , nil)
let destinationRef = CGImageDestinationCreateWithURL(url, kUTTypeJPEG, 1, nil)
let jfifProperties = NSDictionary(dictionary: [kCGImagePropertyJFIFIsProgressive:kCFBooleanTrue])
let properties = NSDictionary(dictionary: [kCGImageDestinationLossyCompressionQuality:0.6,kCGImagePropertyJFIFDictionary:jfifProperties])
CGImageDestinationAddImage(destinationRef!, (sourceImage?.CGImage)!, properties)
CGImageDestinationFinalize(destinationRef!)
Но это не работает в быстром 3.0. CGImageDestinationCreateWithURL дает ошибку. (Все классы CGImage ...) Любая помощь? Благодаря!
«Я нашел следующий код». Не используйте код, который вы не понимаете. – Sulthan
Благодарим вас за помощь. Я очень ценю это! –