Running Photoshop scripts from PHP?

I am creating a web service that revolves around users creating custom image files from the details they enter into a web page. I have PSD files and accompanying scripts, but how can I run Photoshop scripts directly from my PHP code?

I've looked into using blobs, but from what I can see, I can only use them to perform recorded actions in a file.

+3


source to share


2 answers


It is possible, but you need to provide more details on what you want to achieve. Will this server be Mac or Windows? Something that was able to bypass Photoshop.

Here's a built-in example of running a PS script with Photoshop from PHP on a Mac in a terminal.

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

      



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

use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessBuilder;
use Symfony\Component\Filesystem\Filesystem;

$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
}

      

+2


source


It looks like the only way to do this is to record the action loading the script and create a Droplet from the action, then execute it from PHP passing the PSD as a parameter. It's not as elegant as I wanted, but there didn't seem to be any other suggestions.



0


source







All Articles