Copy link to clipboard
Copied
Hi everyone,
I want to make a panel that would register if an image underwent any change (to be more specific, brush stroke). AFAIK this can be done via Generator and imageChanged event but I really this on a panel.
So my questions are:
1) Is there a way to get image changed event on a panel in CC/CC2014? (I think in CC2015 CEP6 there's such an event, but I'm on CC2014)
2) If now, is there a way to communicate between Generator scripts and panels, for example to turn Generator on and off from the panel.
Thanks!
On 2) my solution was to setup a http-server on generator and use Ajax to communicate. Easier than it might sound (Node comes with ready WS-packages) nad gives you really nice responsive results. Starting generator pretty much requires some plugins to be installed, which on CC2014 can be done with a hybrid ZXP. See Generator guidelines/howto/getting started questions for more details
Copy link to clipboard
Copied
On 2) my solution was to setup a http-server on generator and use Ajax to communicate. Easier than it might sound (Node comes with ready WS-packages) nad gives you really nice responsive results. Starting generator pretty much requires some plugins to be installed, which on CC2014 can be done with a hybrid ZXP. See Generator guidelines/howto/getting started questions for more details
Copy link to clipboard
Copied
Thanks Matias, I'll try that!
Copy link to clipboard
Copied
Matias, thanks for you help, I wonder if you can write in mere depth about setting up a connection between generator and html panel? I hoped that jsx would return the state of the generator object but it didn't
Copy link to clipboard
Copied
Actually I found an example of communication through socket.io: Using Photoshop generator plugin together with HTML panel. Pseudo-untested-code · GitHub
However I have a different problem now: everything works when I'm starting generator script from terminal with
node app -f ../Generator
but when I simply restart photoshop it says there's an error with Generator and my script isn't in the menu. Is there a way to understand why?
Copy link to clipboard
Copied
There's "two generators" (i.e. two node.js servers), one built into Photoshop (~production) and one you launch from command line (~development). When you close Photoshop your development server also closes because it loses connection to Photoshop and you need to start it again after starting Photoshop. The error you see could be coming from the internal generator for example if you have invalid files in ~Plug-ins/Generator (i.e. place where internal generator is looking for plugins as opposed to the -f parameter you give to development server). You can find logs from %appdata%\Adobe\Photoshop\Logs (or something).
There's also the web server package that is a bit higher level in Node you can use
var _http = require("http")
var _url = require("url")
var _server = _http.createServer(onServerRequest)
_server.listen(8080)
function onServerRequest (request, response) {
var url = _url.parse(request.url, true, true)
response.setHeader("Access-Control-Allow-Origin", "*") // needed for browser debugging
if (url.pathname === "foo") {
// do something
} else {
response.writeHead(404, 'File not found', {'Content-Type': 'text/plain'})
}
response.end()
},
Copy link to clipboard
Copied
Unfortunately nothing particular is in the log file:
Log file created on Fri Sep 04 2015 13:50:06 GMT+0300 (MSK)
[debug:core 13:50:06.103 generator.js:99:17] Launching with config:
{}
[info:core 13:50:06.500 generator.js:197:25] Detected Photoshop version: 15.2.2
[debug:core 13:50:06.510 generator.js:1631:21] Loading plugin: generator-assets
[debug:core 13:50:06.571 generator.js:1647:21] Plugin loaded: generator-assets
[debug:core 13:50:06.572 generator.js:1631:21] Loading plugin: crema
***************** SVG is enabled - OMG!
requesting document info
[debug:core 13:50:06.709 generator.js:1647:21] Plugin loaded: crema
[debug:core 13:50:06.710 generator.js:1631:21] Loading plugin: generator-getting-started
I tried to run a simple server in Generator via http but I can't understand how to send message to panel (like in socket.io example) %( I know nothing about http
Copy link to clipboard
Copied
Matias, I've tried to use your code (as is) from this topic First Ajax request really slow with Generator but I hadn't received any messages from the panel. Is the code there misses something?