setting Address Book image with MacRuby
-
12-06-2021 - |
Frage
I am trying to set my user's Address Book Image with MacRuby. Here is what I have so far:
framework 'ScriptingBridge'
framework 'AppKit'
download = "/path.png"
data = NSData.dataWithContentsOfFile(download)
bitmap = NSBitmapImageRep.imageRepWithData(data)
final = bitmap.representationUsingType(NSTIFFFileType, properties: nil)
book = SBApplication.applicationWithBundleIdentifier("com.apple.addressbook")
book.myCard.setImage(final)
I have also tried book.myCard.setImage(final.base64Encoding)
, by the way.
What do I need to do to make this work?
Thanks!
Lösung
You must have an NSImage
myImage = NSImage.alloc.initWithContentsOfFile(download)
book = SBApplication.applicationWithBundleIdentifier("com.apple.addressbook")
book.myCard.setImage(myImage)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow