From Photoshop actions to Photoshop scripting?

后端 未结 5 1255
伪装坚强ぢ
伪装坚强ぢ 2021-01-30 07:33

I would like Photoshop to automatically execute the following task for a given folder:

  1. Load all PNG files in a given folder.
  2. Convert each file\'s mode to
相关标签:
5条回答
  • 2021-01-30 08:01

    I realize this is an old question, but what the original post is asking for can be done entirely in a Photoshop Action. Photoshop actions are easy to record - you just hit record and do the steps manually. - including the Open, operations and save step.

    The only trick left is to make the action run in a specific folder rather than the place you record the action. That's easy, however. Use the "Override Open" and "Override Save" options. You invoke this action using File -> Automate -> Batch or from Adobe Bridge using Tools -> Photoshop -> Action

    See this for an example:

    enter image description here

    For some additional tips look here

    0 讨论(0)
  • 2021-01-30 08:17

    I made a script which does the required job:

    #target photoshop
    #strict on
    
    runthis();
    function runthis()
    {
        var path = "/d/PhotoshopScript/Images/";
    
         var inputFolder = new Folder(path );
        var inputFiles = inputFolder.getFiles("*.png");
    
        for(index in inputFiles)
        {
            // open the file
            var fileToOpen = new File(inputFiles[index]);
            open(fileToOpen);
    
            // Change mode to rgb
            activeDocument.changeMode(ChangeMode.RGB);
            // add a new layer
            activeDocument.artLayers.add();
    
            //save
            var psdOptions = new PhotoshopSaveOptions();
            psdOptions.alphaChannels = true;
            psdOptions.annotations = false;
            psdOptions.embedColorProfile = false;
            psdOptions.layers = true;
            psdOptions.spotColors = false;
    
            var file = new File(path + GetFileName(String(inputFiles[index])));
            activeDocument.saveAs(file, psdOptions);
    
            activeDocument.close();
    
            // dispose
            fileToOpen = null;
            psdOptions = null;
            file  = null;
        }
        // dispose
        inputFolder = null;
        inputFiles = null;
    
    }
    
    function GetFileName(fullPath)
    {
        var m = fullPath.match(/(.*)[\/\\]([^\/\\]+)\.\w+$/);
        return m[2];
    }
    

    It can be improved in many ways, but I hope it helps.

    0 讨论(0)
  • 2021-01-30 08:17

    Let me answer the question you actually asked in bold: There is a tool that automatically generates the Javascript for the actions and events that are taking place in Photoshop. It is called the Script Listener. After using the script listener to record your actions, review the log and make your selective edits.

    To begin using the Script Listener

    1. Close Photoshop
    2. Copy the ScriptListener.8li file from the C:\Program Files\Adobe\Adobe Photoshop CS5\Scripting\Utilities folder
    3. Paste the file to the C:\Program Files\Adobe\Adobe Photoshop CS5\Plug-ins\Automate folder.
    4. Run Photoshop, perform actions you want to happen in your script.
    5. Close Photoshop, delete the copy of the script listener from the Automate folder.
    6. Edit the log file that is placed on your desktop by the script listener.

    To get your new fangled script into Photoshop place the file you've created with a jsx extension into C:\Program Files\Adobe\Adobe Photoshop CS5\Presets\Scripts.

    0 讨论(0)
  • 2021-01-30 08:18

    To update Kevin's answer, ScriptListener is now hidden in a different place:

    http://www.adobe.com/devnet/photoshop/scripting.html

    inside "Scripting Listener Plug-in". The plugin directory in Windows has also changed, typically:

    C:\Program Files\Common Files\Adobe\Plug-Ins\CC

    0 讨论(0)
  • 2021-01-30 08:20

    look for the file SaveAsDifferentFileType.jsx on your computer, i think you could use this as starting point.

    There is now way that i know of to generate this code automatically. I think there is no way around learning how it works:

    Here the documentation: http://www.adobe.com/devnet/photoshop/scripting.html And here a tutorial that will tell you where to begin: http://morris-photographics.com/photoshop/tutorials/scripting1.html

    If you are using a MAC you could try the Automator Photoshop actions: http://www.completedigitalphotography.com/?p=339

    They will let you do what you want, without any programming know-how.

    0 讨论(0)
提交回复
热议问题