skip to Main Content

I’m creating a web service which revolves around users creating custom image files from details they enter on the webpage. I have the PSD files completed, along with the accompanying scripts, but how can I launch the Photoshop scripts directly from my PHP code?

I looked into using Droplets, but from what I can see I can only use these to perform recorded actions on a file.

2

Answers


  1. Chosen as BEST ANSWER

    Looks like the only way it can be done is to record an action loading the script and create a Droplet out of the action, then execute it from PHP passing the PSD as a parameter. It's not as elegant as I wanted, but there doesn't seem to be any other suggestions.


  2. It’s sort of possible, but you’ll need to provide more details about what you wish to accomplish. Would this server be a mac or windows? Something that was capable ofrunning Photoshop.

    Here’s an inline example of executing a PS script with Photoshop from PHP on a mac within Terminal.

    $ php -r "`open -b "com.adobe.Photoshop" myPhotoshopScript.jsx`;"
    

    Or better yet, use the Symfony Process and Filesystem components to manage this.

    use SymfonyComponentProcessProcess;
    use SymfonyComponentProcessProcessBuilder;
    use SymfonyComponentFilesystemFilesystem;
    
    $fs = new Filesystem();
    
    $photoshopProcessBuilder = new ProcessBuilder();
    $photoshopProcessBuilder->setPrefix('open -b "com.adobe.Photoshop"');
    
    if ($fs->exists($photoshopScriptFile)) {
    
        $photoshopProcessBuilder->setArguments(array($photoshopScriptFile));
    
        $photoshopScriptRunnerProcess = $photoshopProcessBuilder->getProcess();
        $photoshopScriptRunnerProcess->run();
    
        if (!$photoshopScriptRunnerProcess->isSuccessful()) {
            throw new RuntimeException($photoshopScriptRunnerProcess->getErrorOutput());
        }
    
        // do some other stuff
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search