Skip to content

Instantly share code, notes, and snippets.

@hermannsorgel
Created February 26, 2023 13:48
Show Gist options
  • Select an option

  • Save hermannsorgel/98676034cd3ddbbb07e7e3a82d854e42 to your computer and use it in GitHub Desktop.

Select an option

Save hermannsorgel/98676034cd3ddbbb07e7e3a82d854e42 to your computer and use it in GitHub Desktop.
Simple script to copy Pixelmator document to clipboard as JPEG
ObjC.import('AppKit');
$.NSPasteboard.generalPasteboard.clearContents;
const app = Application('Pixelmator Pro')
const doc = app.document()[0]
const fm = $.NSFileManager.defaultManager
const exportFormat = 'JPEG'
const tempPath = '/var/tmp/export.jpg'
const nsUrl = $.NSURL.fileURLWithPath(tempPath);
app.export(doc, {to: tempPath, as: exportFormat})
$.NSPasteboard.generalPasteboard.writeObjects([nsUrl.js])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment