0

So I have a personal website, and I have a button that I want to use to open photoshop and run a script for me. How do I do this?

Eric Chu
  • 1,649
  • 3
  • 20
  • 26
  • Well, I have tried reading the photoshop js reference, but not sure how I can use JS to OPEN photoshop – Eric Chu Apr 20 '15 at 18:50

3 Answers3

1

It is not possible. It would pose a huge security risk to allow javascript to open programs on client side.

mbsingh
  • 499
  • 10
  • 26
  • It is possible. See iTunes: https://itunes.apple.com/us/app/alarm-clock-pro/id335678373?mt=8. There is a "View in iTunes" button which opens iTunes. – Sumner Evans Apr 20 '15 at 18:15
  • Not sure but that has probably something to do with the iTunes application itself. Perhaps a service/deamon running. See this: http://stackoverflow.com/questions/877774/how-can-i-run-a-program-or-batch-file-on-the-client-side – mbsingh Apr 20 '15 at 18:23
  • 1
    In Chrome it's called an external protocol request. This is what I got when clicking the button to open in itunes "Google Chrome needs to launch an external application to handle itmss: links. The link requested is itmss://itunes.apple.com/us/app/alarm-clock-pro/id335678373?mt=8ign-msr=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F29755307%2Fhow-do-you-open-photoshop-with-javascript." "The following application will be launched if you accept this request: iTunes.app" – Asta Apr 20 '15 at 18:31
  • So I guess I need to do an external protocol request? any ideas how I implement this into JS? – Eric Chu Apr 20 '15 at 18:53
  • AFAIK, Photoshop doesn't have protocol requests, so it still wouldn't work. – Jon Egeland Apr 20 '15 at 21:43
0

This has been up for awhile, but if the solution to this in node is to use a child_process.

you can npm install child_process

and the code to run executables would be to do

const exec = require("child-process").execFile;

var process = exec("Photoshop.exe", [*add options here*], {cwd:"C:/*path to photoshop*"});

you can do a lot of cool things afterwards like event handlers

process.on("close", code => {
  console.log("process closed with code: "+ code)
})

process.on("exit", code => {
  console.log("process exited with code: "+ code)
})

process.stdout.on("data", data => {
  console.log(data)
})

You can read the Docs here: https://nodejs.org/api/child_process.html

Eric Chu
  • 1,649
  • 3
  • 20
  • 26
-1

maybe this Code will open image in photoshop with the help of javascript. You just need to place your image file into photoshop->sample folder nothing more than that and you done with it.

var fileRef = new File(app.path.toString() + “/Samples/test.jpg”); // ‘samples’ is a folder resides in Program Files\Adobe\Adobe Photoshop CS5\samples
//open (fileRef);
var doc = open(fileRef);
// get document name (and remove file extension)
var name = tempName[0];
// convert to RGB; convert to 8-bpc; merge visible
doc.changeMode(ChangeMode.RGB);
doc.bitsPerChannel = BitsPerChannelType.EIGHT;
doc.artLayers.add();
doc.mergeVisibleLayers();

// rename layer; duplicate to new document
var layer = doc.activeLayer;
layer.name = tempName[0];
layer.duplicate(newDoc, ElementPlacement.PLACEATBEGINNING);
// close imported document
doc.close(SaveOptions.DONOTSAVECHANGES);