Result Values From a JSX Script

When writing Generator plugins for Photoshop you often have to call snippets of JSX code which do your actual work in PS.  This integration is a little tricky to work with, especially when dealing with finding out what happened in your JSX script when it executed in PS!

Basically, each JSX script you call will be executed in the JSX interpreter, not in the node container your generator is running in.  Adobe provides only one return value that your JSX can run, a variable called ‘result’.  If you carefully construct your script to catch all exceptions during execution you will be able to set this result variable to detect issues that might occur during execution.

You have to remember though:  the result variable can only be the *last* thing you set in your JSX code, you cannot execute anything after doing something like this:

try {


    function blinkImageProcess() {


        return 'OK';

    // JSX interpreter looks for the 'result' var and returns it to the caller

    result = blinkImageProcess();
} catch (e) {
    result = e.message;

Adding code after the ‘result = …’ statement above will cause the JSX interpreter to return ‘undefined’ for ‘result’! Major fail.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s