splash/Sources/SplashImageGen/Extensions/CGImage+WriteToURL.swift
Marcin Chojnacki c30a8277f7
Add ImageIO import allowing to build the tool using recent toolchain (#127)
Should resolve:
```
error: cannot find 'CGImageDestinationCreateWithURL' in scope
```
build errors.
2022-06-08 21:43:37 +02:00

21 lines
404 B
Swift

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