Post by Bailey on May 25, 2019 4:56:22 GMT
app.activeDocument.activeLayer = app.activeDocument.artLayers; //set the top layer in stack as active layer
app.activeDocument.artLayers.add(); //add blank layer
app.activeDocument.activeLayer = app.activeDocument.artLayers; //set the new layer as active layer
If you want to use this code, simply copy/paste it into any new text file using your favourite text editor. Personally I use the Netbeans IDE, but this would be gross overkill unless you are a web site developer. I would steer away from MS Word because any hidden/embedded formatting in the saved text file might cause the script to not run. Windows Notepad, Wordpad or the Mac. equivalents should be fine.
Save the text file anywhere you like on your PC with any name you like but make sure you give the filename a .jsx extension.
Open any image with at least one layer in your PSE editor.
Then navigate to your .jsx file and select it.
If the script runs successfully, a new blank layer will appear at the top of your image file's layer stack.
The main advantage scripts have over actions is their immense power and flexibility. With scripting you can add logic to execute code only when certain conditions are met (files are a certain size, resolution, type etc etc etc) and script can be coded to run on only the active opened document or on all the documents in the Photo Bin in one go.
With scripting you can also run a script on all the image files in a particular folder or selected folders on your hard-drive.
There are many other advantages of scripting over actions as well.