Highlighted

Text Layers color change Action

Explorer ,
Feb 06, 2017

Copy link to clipboard

Copied

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!

Adobe Community Professional
Correct answer by 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.textItem.color = textColor;

    }

    function getTextLayers (doc, layers) {

        layers = layers || [];

        for (var i = 0, il = doc.layers.length; i < il; i ++) {

            if (doc.layers.typename == "LayerSet") {

                getTextLayers(doc.layers, layers)

            } else {

                if (doc.layers.kind == "LayerKind.TEXT") {

                    layers.push(doc.layers)

                }

            }

        }

        return layers

    }

})();

TOPICS
Actions and scripting

Views

4.4K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Text Layers color change Action

Explorer ,
Feb 06, 2017

Copy link to clipboard

Copied

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!

Adobe Community Professional
Correct answer by 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.textItem.color = textColor;

    }

    function getTextLayers (doc, layers) {

        layers = layers || [];

        for (var i = 0, il = doc.layers.length; i < il; i ++) {

            if (doc.layers.typename == "LayerSet") {

                getTextLayers(doc.layers, layers)

            } else {

                if (doc.layers.kind == "LayerKind.TEXT") {

                    layers.push(doc.layers)

                }

            }

        }

        return layers

    }

})();

TOPICS
Actions and scripting

Views

4.4K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 06, 2017 0
Most Valuable Participant ,
Feb 06, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 06, 2017 0
Adobe Community Professional ,
Feb 06, 2017

Copy link to clipboard

Copied

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.textItem.color = textColor;

    }

    function getTextLayers (doc, layers) {

        layers = layers || [];

        for (var i = 0, il = doc.layers.length; i < il; i ++) {

            if (doc.layers.typename == "LayerSet") {

                getTextLayers(doc.layers, layers)

            } else {

                if (doc.layers.kind == "LayerKind.TEXT") {

                    layers.push(doc.layers)

                }

            }

        }

        return layers

    }

})();

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 06, 2017 4
Explorer ,
Feb 07, 2017

Copy link to clipboard

Copied

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

Thanks a lot!!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 07, 2017 0
Zack0101 LATEST
New Here ,
Sep 25, 2020

Copy link to clipboard

Copied

Heey Can this script pick colors from pictures instead of adding the hex manually ? If there any script that could take colors from the picture in the design and put it on text ?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 25, 2020 0