• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Text Layers color change Action

Explorer ,
Feb 06, 2017 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!

TOPICS
Actions and scripting

Views

5.7K

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
community guidelines

correct answers 1 Correct answer

Advocate , Feb 06, 2017 Feb 06, 2017

There you go buddy.

 

PSD Script: Set Random text color from given array

 

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 textLa
...

Votes

Translate

Translate
Adobe
Community Expert ,
Feb 06, 2017 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.

Votes

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
community guidelines
Advocate ,
Feb 06, 2017 Feb 06, 2017

Copy link to clipboard

Copied

There you go buddy.

 

PSD Script: Set Random text color from given array

 

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
	}
})();

 

Votes

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
community guidelines
Explorer ,
Feb 07, 2017 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!!!

Votes

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
community guidelines
Community Beginner ,
Aug 10, 2021 Aug 10, 2021

Copy link to clipboard

Copied

LATEST

Hi Tomas,

Could you please show me how to do this for selected text layers? Only for the text layers inside a folder. 

Also, without adding colors randomly, I need it to be the order of Hexcode. 

 

I'm really be grateful if you can show me how to do this. TIA.

Votes

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
community guidelines
New Here ,
Sep 25, 2020 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 ?

Votes

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
community guidelines