splash/Sources/SplashImageGen/Extensions/CGImage+WriteToURL.swift

20 lines
389 B
Swift
Raw Normal View History

2018-08-24 18:42:07 +02:00
/**
* Splash
* Copyright (c) John Sundell 2018
* MIT license - see LICENSE.md
*/
#if os(macOS)
import Foundation
extension CGImage {
func write(to url: URL) {
let destination = CGImageDestinationCreateWithURL(url as CFURL, kUTTypePNG, 1, nil)!
CGImageDestinationAddImage(destination, self, nil)
CGImageDestinationFinalize(destination)
}
}
#endif