To reproduce what I’m looking to do with scripting (JSX) in Photoshop:
- Select part of image with transperant background (no background layer)
- File -> New *1
*1 – Photoshop will then automatically crop your selection to the boundaries of your image and use that as widht & height, how can I get this information through scripting in JSX?
I’ve managed to get the layer size boundaries, but that’s not what I want. I want to get the size from whats on the clipboard.
I looked through all of the docs, and figured out that you get an ArtLayer when pasting – I could then get the bounds of this artlayer and crop the image. Incase anyone else needs it I put my working script here: https://gist.github.com/amaeland/49f84bb14c76c35e825f
Honestly this answer depends on your version of Photoshop, but I’m going to assume you’re working with the most recent version.
Luckily the newest version (CC 2015) has some built-in clipboard interactions, which you can read up on here.
If this isn’t what you need, then I suggest to keep looking through that document. If nothing turns up it may not be very exposed for you to find at which point you may have more luck getting the height and width another way and then trying to insert it yourself into the new document dialog.
If you have a different version of Photoshop, check the documentation here (CS2-CC 2015.)
Source : Link , Question Author : am_ , Answer Author : Hanna