Open llsc12 opened 1 month ago
import PlaygroundSupport
import Foundation
// put file.cape in the Resources folder of the macos playground
let fileURL = Bundle.main.url(forResource: "file", withExtension: "cape")!
let dec = PropertyListDecoder()
struct CapeFile: Codable {
let Author: String
let Cursors: [String: Cursor]
struct Cursor: Codable {
let Representations: [Data]
}
}
let cape = try dec.decode(CapeFile.self, from: Data(contentsOf: fileURL))
// this iterates through capes and writes the tiff files
// saved to ~/Desktop/dumped/
try cape.Cursors.forEach { (key: String, value: CapeFile.Cursor) in
let loc = URL.desktopDirectory.appendingPathComponent("dumped").appendingPathComponent(key).appendingPathExtension("tiff")
try FileManager.default.createDirectory(at: URL.desktopDirectory.appendingPathComponent("dumped"), withIntermediateDirectories: true)
try value.Representations.first?.write(to: loc)
}
In case anyone needs this, hope it helps.
Dragging images out of the editor into a folder doesn't copy it but rather removes it and there seems to be no way to export images as a result. Thanks in advance.