Search code examples
macoscocoansimage

Is that possible to open NSImage with Photoshop in Cocoa


Is that possible to open NSImage with Photoshop in Cocoa? And how to do it?


Solution

  • I would try the following (with Objective-C method hints).

    1. Find a temporary folder

      Use -[NSFileManager URLForDirectory: inDomain: appropriateForURL: url create: error:]

      (Or the Desktop folder while testing)

    2. Save the NSImage as a file in the temporary folder

      (Use NSUUID to get a random file name)

      Get the NSBitmapImageRep from the NSImage

      Convert the NSBitmapImageRep to NSData

      Use -[NSData writeToURL: atomically:]

    3. Open the file in Photoshop

      Use -[NSWorkspace openFile: withApplication:]