Mobile app version of vmapp.org
Login or Join
Margaret771

: How can I get the boundaries (width & height) of the current clipboard image? To reproduce what I'm looking to do with scripting (JSX) in Photoshop: Select part of image with transperant background

@Margaret771

Posted in: #PhotoshopScripting

To reproduce what I'm looking to do with scripting (JSX) in Photoshop:


Select part of image with transperant background (no background layer)
Copy
File -> New *1
Paste


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

EDIT -
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: gist.github.com/amaeland/49f84bb14c76c35e825f

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Margaret771

2 Comments

Sorted by latest first Latest Oldest Best

 

@Sent7350415

I use AppleScript to script Photoshop, not JavaScript, but hopefully this solution will still work for you.

To get the size of the image that is on the clipboard, create a new Photoshop document — it will be created at the size of what is on the clipboard — and then get the width and height of the new document, and then close the new document without saving.

10% popularity Vote Up Vote Down


 

@Reiling762

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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme