3 Replies Latest reply on Feb 7, 2017 5:49 AM by mirza5313

    Text Layers color change Action

    mirza5313 Level 1

      I need a Photoshop action/script for a file which contains around 50 text layers. I need the action/script to alter the colour of each text layer and apply new colours to each one individually. Each time I run the action, the script should randomise the colours again.

       

      The new colours will be preset from a group of colours e.g.

       

      "Colour group one": #000000, #f3f3f3, #76f8f7, #333333, #454566, #d87d56

      "Colour group two": #111111, #c7c8c7, #f9h9d9, #999999, #d3d2d2, #a8aha8

      Etc....

       

      Example:

       

      I have a file containing 50 text layers. I want to change all of the text layers to the "Colour Group One" colours. I run the script/action and each text layer will have one of the colours from "Colour Group One". Each time I run the action, each text layer will change colours again.

       

      I hope this is clear but understand that it might not be! (I have add an example image to text color change.)

      after.jpg

       

       

      Thanks in advance!

        • 1. Re: Text Layers color change Action
          pixxxel schubser MVP & Adobe Community Professional

          Hi mirza5313,

          Do you search for help to writing a script?

          Or do you search for someone who is writing the script for you?

           

          In both cases: please upload an example file for testing.

          • 2. Re: Text Layers color change Action
            Tomas Sinkunas Adobe Community Professional

            There you go buddy.

             

            https://bitbucket.org/snippets/rendertom/p457E/psd-script-set-random-text-color-from

             

            Simply add hex colours to colorArray variable and you should be golden

             

             

            // Script applies random color from given color array
            // to all text layers in the document.
            // 
            // by Tomas Sinkunas www.rendertom.com
            
            (function(){
                #target photoshop
            
                // Define HEX colors separated by comma
                var colorArray = ["#000000", "#f3f3f3", "#76f8f7", "#333333", "#454566", "#d87d56"];
                
                // Collect all text layers in the document
                var textLayers = getTextLayers(app.activeDocument);
            
                // Loop through all text layers in the document
                for (var t = 0, tl = textLayers.length; t < tl ; t ++) {
                    // Get random color from color array
                    var randomColor = colorArray[Math.floor(Math.random() * colorArray.length)];
                    // Remove pound sing from the color value
                    if (randomColor.charAt(0) === "#")
                        randomColor = randomColor.substr(1);
            
                    // Initiate new color
                    var textColor = new SolidColor;
                        textColor.rgb.hexValue = randomColor;
            
                    // Set text Layer Color
                    textLayers[t].textItem.color = textColor;
                }
            
                function getTextLayers (doc, layers) {
                    layers = layers || [];
                    for (var i = 0, il = doc.layers.length; i < il; i ++) {
                        if (doc.layers[i].typename == "LayerSet") {
                            getTextLayers(doc.layers[i], layers)
                        } else {
                            if (doc.layers[i].kind == "LayerKind.TEXT") {
                                layers.push(doc.layers[i])
                            }
                        }
                    }
                    return layers
                }
            })();
            
            3 people found this helpful
            • 3. Re: Text Layers color change Action
              mirza5313 Level 1

              Thanks Tomas Sinkunas for your prompt reply and script... This is amazing script just what i wanted.....

               

               

              Thanks a lot!!!