Skip to main content
Retsied
Known Participant
April 13, 2019
Question

Script to resize artLayer by dragging one side only (maintain current height)

  • April 13, 2019
  • 3 replies
  • 1966 views

I have an art layer that essentially is a simple rounded rectangle. I would like a script thats able to resize this layer to a given pixel width by dragging only the left side, maintaining its current height. Any help much appreciated. Thanks!

This topic has been closed for replies.

3 replies

Legend
April 23, 2019

var x = 120; // new width in percent

app.activeDocument.activeLayer.resize(x, 100, AnchorPosition.MIDDLERIGHT);

JJMack
Community Expert
Community Expert
April 23, 2019

For Retsied

So Photoshop DOM Layer Resize is more or less a subset of Layer Transform.  With Photoshop  Transform UI and Adobe's Scriptlisener Plug-in you can actually program a full layer Transform into a Photoshop Script.  Code a Transform function for layers.

JJMack
JJMack
Community Expert
Community Expert
April 14, 2019

By layer length I assume you mean width or height since you wrote one side  Right, Top, left or bottom.

If you know the width or height you want, the layer you want resized  and do not mind the rounded corners distortion you should be able the script the layer resize.  If you want you shrink it  the selection and move would be more involved as would growing it wider or taller.

JJMack
Retsied
RetsiedAuthor
Known Participant
April 18, 2019

Yes, I'm fine distorting the rounded corners. I also know the length (width) I want the layer, just need to know how to assign this to the rectangle by dragging only the left side to enlarge. I'm not sure how to write this in the script.

JJMack
Community Expert
Community Expert
April 18, 2019

You are doing a layer resize. You may be able to use action manager code to do it like you can using Free transform and chaning one side position. Or you may need to do it in two steps  one resize the layer to the size you want and a second step to align the layer to the position your want.

JJMack
JJMack
Community Expert
Community Expert
April 14, 2019

If its is a solid color fill Ctrl+T Free Transform can do the howevet the roundered cornor will distort. However you can select half of it abd nove the inward to shrink it withour distortion.

JJMack
Retsied
RetsiedAuthor
Known Participant
April 14, 2019

JJMack, I appreciate the response, however I really need to do this via script. The reason being, is because I'm trying to set the length to a given pixel dimension that is equivalent to another layers length. I've extracted this layers length as a new variable, and need to set the rectangle length equal to it by only moving the left side only. Thanks!