Vector rectangle shape made with ExtendScript?

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Kukurykus, Tom, xbytor

Posts: 1
Joined: Mon Feb 25, 2019 5:04 pm

Vector rectangle shape made with ExtendScript?

Post by fred »


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,


User avatar
Posts: 6
Joined: Mon Apr 16, 2018 8:53 am
Location: Finland

Re: Vector rectangle shape made with ExtendScript?

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

Posts: 15
Joined: Wed Feb 22, 2017 5:37 pm
Location: INDIA

Re: Vector rectangle shape made with ExtendScript?

Post 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.
(1.37 KiB) Downloaded 189 times