Descriptor-Info

Upload Photoshop Scripts, download Photoshop Scripts, Discussion and Support of Photoshop Scripts

Moderators: xbytor, DavideBarranca, Paul MR

JavierAroche
Posts: 29
Joined: Sat Jul 30, 2016 3:52 am
Location: San Francisco
Contact:

Descriptor-Info

Postby JavierAroche » Sat Dec 24, 2016 6:53 am

Hey guys, I wanted to share a little JSX module I made to recursively get all the properties in an ActionDescriptor. It's always been a struggle to read the contents of an Action Descriptor, so I wanted something fast that could give me all this information without having to loop through every property manually.

I've seen many scripts out there trying to accomplish something similar, all of them with different and interesting approaches. I've definitely picked up a lot of ideas from these forums. I wasn't getting what I was looking for unfortunately, so I made my own module. This will mostly be used as a read-only JSON to look for the property that you need.

Here you will find the public repo for the project with all its information. Feel free to bring up ideas, bugs, compatibility issues, etc.
https://github.com/JavierAroche/descriptor-info

Here's an example of how to use it.

Usage
descriptorInfo.getProperties( desc );
// Sample code for getting Descriptor properties with getProperties

Code: Select all

// Include the descriptorInfo module 
#include "~/Development/personal/descriptor-info/jsx/descriptor-info.jsx" 
 
// ActionDescriptor example 
var ref = new ActionReference(); 
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
var desc = executeActionGet(ref);   
 
// Retrieve its properties by running the getProperties function, passing the ActionDescriptor as a param 
var descObject = descriptorInfo.getProperties( desc );


JSON object example: https://github.com/JavierAroche/descriptor-info#getproperties

Supported Descriptors
DescValueType.BOOLEANTYPE
DescValueType.CLASSTYPE
DescValueType.DOUBLETYPE
DescValueType.ENUMERATEDTYPE
DescValueType.INTEGERTYPE
DescValueType.LISTTYPE
DescValueType.OBJECTTYPE
DescValueType.REFERENCETYPE
DescValueType.STRINGTYPE
DescValueType.UNITDOUBLE
DescValueType.ALIASTYPE
DescValueType.RAWTYPE

Known Limitations
REFERENCETYPE Descriptors will only return the Descriptor linked, but not it's actual properties. Adding this without properly testing can fall in an endless loop.
RAWTYPE Descriptors, usually labeled "legacyContentData", will return the value as unicode. You will have to parse it separately as the data varies too much.

Hope you guys find this useful and helps you better understand Action Descriptors. Feedback is always appreciated.

PS. If you're using my Brackets-to-Photoshop extension, you can use the console.stringify function to print out the JSON descriptor to the console.
https://github.com/JavierAroche/brackets-to-photoshop

Code: Select all

// Retrieve its properties by running the getProperties function, passing the ActionDescriptor as a param 
var descObject = descriptorInfo.getProperties( desc ); 
 
console.stringify( descObject );



User avatar
Kukurykus
Posts: 114
Joined: Mon Jul 25, 2016 12:36 pm

Re: Descriptor-Info

Postby Kukurykus » Sun Dec 25, 2016 12:48 am

I'm glad to see someone does programs like this one, and want to share with others, good move!

JavierAroche
Posts: 29
Joined: Sat Jul 30, 2016 3:52 am
Location: San Francisco
Contact:

Re: Descriptor-Info

Postby JavierAroche » Wed Dec 28, 2016 3:50 am

Thanks Kukurykus! Sharing is the only way to learn! :)

JavierAroche
Posts: 29
Joined: Sat Jul 30, 2016 3:52 am
Location: San Francisco
Contact:

Re: Descriptor-Info

Postby JavierAroche » Sat Jan 14, 2017 7:27 pm

Just a little update on this forum. Main discussion has been in the Adobe forum
https://forums.adobe.com/thread/2254499

I just realized v1.0.2 of my descriptor-info JSX module. I've simplified the object returned to make it more useable. I've updated the object examples in the README to show the new changes.

Please check it out, if you have some time.
https://github.com/JavierAroche/descriptor-info

v1.0.2 (Jan 13 2017)

Added optional params to retrieve extended descriptor information
Updated example to reflect new optional params


Return to “Photoshop Scripts”

Who is online

Users browsing this forum: No registered users and 3 guests