0

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!

dejay
  • 758
  • 2
  • 6
  • 18

1 Answers1

0

You must have an NSImage

myImage = NSImage.alloc.initWithContentsOfFile(download)
book = SBApplication.applicationWithBundleIdentifier("com.apple.addressbook")
book.myCard.setImage(myImage)
jackjr300
  • 7,111
  • 2
  • 15
  • 25