I've created a photoshop action that adds a string of white text to a photo. In this action, I wrote a script that extends the canvas size and resizes the text within the extra canvas space to fit the dimensions of the image, creating a 'text tab' on the photo. However, after the action and script are implemented, the color of the text in the tab is often... not white.
What is the scripting syntax I can use to change the color of the text layer to white, to ensure it doesn't randomly change color?
For reference, here is the portion of my script that edits the text layer:
#target photoshop
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.INCHES;
var doc = app.activeDocument;
var layer = doc.activeLayer;
app.preferences.rulerUnits = Units.PIXELS;
//create the color for the tab extension
var black = new SolidColor();
black.rgb.hexValue = "111111";
app.backgroundColor = black;
//*****************************FOR EXTENDING CANVAS AND POSITIONING/RESIZING THE TEXT LAYER*********************************
var orgWidth = doc.width;
var orgHeight = doc.height;
if(orgWidth>orgHeight) //if document is landscape, resize text to fill a smaller portion of the tab
{
layer.resize(((orgWidth-orgWidth*.2)/(layer.bounds[2]-layer.bounds[0]))*100,(orgWidth*.017/(layer.bounds[3]-layer.bounds[1]))*100,AnchorPosition.TOPLEFT);
doc.resizeCanvas(doc.width, (orgHeight + orgWidth*.04), AnchorPosition.TOPCENTER);
layer.translate(undefined, new UnitValue(0-layer.bounds[1].as('px'),'px'));
layer.translate(undefined, orgHeight);
layer.translate(undefined, (orgWidth*.02-((layer.bounds[3]-layer.bounds[1])/2.3)));
}
else //otherwise, resize text to fill a larger portion of the tab
{
layer.resize(((orgWidth-orgWidth*.05)/(layer.bounds[2]-layer.bounds[0]))*100,(orgWidth*.017/(layer.bounds[3]-layer.bounds[1]))*100,AnchorPosition.TOPLEFT);
doc.resizeCanvas(doc.width, (orgHeight + orgWidth*.04), AnchorPosition.TOPCENTER);
layer.translate(undefined, new UnitValue(0-layer.bounds[1].as('px'),'px'));
layer.translate(undefined, orgHeight);
layer.translate(undefined, (orgWidth*.02-((layer.bounds[3]-layer.bounds[1])/2.3)));
}
var layerWidth = Number(layer.bounds[2] - layer.bounds[0]);
var dX = (orgWidth - layerWidth) / 2 - Number(layer.bounds[0]);
layer.translate(dX, undefined);
doc.flatten(); //flatten the text into the photo
app.preferences.rulerUnits = originalRulerUnits;
It might be easier for you to code the text addition. Here's a handy function I wrote for such an occasion. The text is justified centre, but you can adjust that. (I would have included that part of the function but it looks like IF spaghetti)