Skip to content

Instantly share code, notes, and snippets.

@littlebusters
Created December 23, 2015 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save littlebusters/e880bb92d7f45d7c9c63 to your computer and use it in GitHub Desktop.
Save littlebusters/e880bb92d7f45d7c9c63 to your computer and use it in GitHub Desktop.
var openDialog = NSOpenPanel.openPanel();
openDialog.setCanChooseFiles(true);
openDialog.setCanChooseDirectories(false);
openDialog.setAllowsMultipleSelection(false);
openDialog.setCanCreateDirectories(false);
openDialog.setTitle('Choose File');
if( openDialog.runModal() == NSOKButton ) {
var fileURL = openDialog.URLs().firstObject();
} else {
return false;
}
var regexp = new RegExp( 'file://', 'ig' );
var fileURL = fileURL.replace( regexp, '' );
var option = 'mogrify "' + fileURL + '" -background white -alpha remove';
var task = NSTask.new();
task.setLaunchPath( '/bin/bash' );
task.setArguments(['-c', option]);
task.launch();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment