Skip to content

Instantly share code, notes, and snippets.

@magicien
Created August 22, 2017 22:52
Show Gist options
  • Save magicien/b778413bda8931569120a18e7ff50e51 to your computer and use it in GitHub Desktop.
Save magicien/b778413bda8931569120a18e7ff50e51 to your computer and use it in GitHub Desktop.
let url = URL(fileURLWithPath: pngFileName, relativeTo: directoryPath)
// let reddishImage = NSImage(contentsOf: url)
let cgDataProvider = CGDataProvider(url: url as CFURL)!
let cgImage = CGImage(pngDataProviderSource: cgDataProvider, decode: nil, shouldInterpolate: false, intent: CGColorRenderingIntent.defaultIntent)!
let imageSize = CGSize(width: cgImage.width, height: cgImage.height)
let correctImage = NSImage(cgImage: cgImage, size: imageSize)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment