Script to Resize Text/Type Layer and Position

New Here ,
Jul 23, 2022 Jul 23, 2022

Copy link to clipboard

Copied

Desperate for some scripting help for Photoshop (v 23.4.1, Windows 10).

I have a text layer that I want to be able to resize and reposition. I've searched through countless posts, tried various examples, but can't seem to quite get it. Hoping someone can help. Here is the manual way of doing it:

 

1. Start with a word with certain font settings. The type layer size is set to 1920 x 540, position 0,0, all in pixels.

Kathryn22063756378e_0-1658639764303.png

 

2. Update the text to a new word. The width has changed (to 1129.79), and the x position has changed (409.85).

Kathryn22063756378e_1-1658639856582.png

 

3. Update the transform values back to 1920 pixels for width and 0 pixel for x position:

Kathryn22063756378e_2-1658639982023.png

 

This is what I would like to accomplish via scripting. The replacement of whatever word exists in the layer, and then resizing so that it is 1920 width, and back at 0 position for x. The text will stretch accordingly, while maintaining the 1920 width and centered in the layer, which is the exact result I want.

Basic script I have to start to update the layer is:

 

var doc = app.activeDocument;
var wordLayer = doc.layers.getByName('WORD LAYER');
wordLayer.kind = LayerKind.TEXT;
var wordLayerText = wordLayer.textItem;
var wordText = "cat";
wordLayerText.contents = wordText;

 

All attempts at adding the transformation methods have failed, especially when trying to do it via pixel values.

Thanks to anyone for their time and help.

Cheers!

 

TOPICS
Actions and scripting

Views

54

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
community guidelines
Adobe Community Professional ,
Jul 23, 2022 Jul 23, 2022

Copy link to clipboard

Copied

LATEST

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