Page 1 of 1

Vector rectangle shape made with ExtendScript?

Posted: Tue Feb 26, 2019 9:59 am
by fred
Hello,

Is it possible to create a vector rectangle shape (rectangle tool) with ExtendScript?

I just want to create a 1px border around my PSD file and keep it vector in order to change the width later (to 2px for example).

Thanks for your help,

fred

Re: Vector rectangle shape made with ExtendScript?

Posted: Tue Feb 26, 2019 12:29 pm
by joonaspaakko
Couple Action methods come to mind. Neither of these use shape layers but should be about as flexible in this case, if not more so...

Method #1
  • Layer > New Fill Layer...
  • Layer fill: 0
  • Layer style: Stroke (inset)
A possible downside is that since the stroke is inset, it might hide things behind it. For example, if you have a 100x100px photo and you give it a 100px stroke, the document will be nothing but stroke.

Method #2
  • Image > Trim... - (Check: Top left pixel color)
  • Image > Canvas Size... (Note that you can make the action stop here so you can set the relative width and height every time you run the action)
I added the Image > Trim there for the sake of the easy edits, but I thought I'd add a warning that it could totally destroy your image before it even gets to add the stroke. It would be better left off. Another possible downside is that the document size increases by the stroke width times two. This could also be considered a big plus as it doesn't cover anything like method #2.

Re: Vector rectangle shape made with ExtendScript?

Posted: Tue Mar 05, 2019 5:31 am
by AnilTejwani
Here is script (zip fiel attached) that creates a 2px wide (stroke) rectangle around the full width/height of PSD.

Hope it helps.