Copy link to clipboard
Copied
I've done quite some research on this and I've seen the post from people (like for ex. c.pfaffenbichler ) saying it's impossible to retrieve this data.
It's obviously stored -somewhere- but it doesn't appear that you can retrieve this information in any way.
I've used this code to retrieve information from the transform -tool of a Smart Object:
var idnull = charIDToTypeID("null");
var layerReference = new ActionReference();
layerReference.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
var layerDescriptor = new ActionDescriptor();
layerDescriptor.putReference(idnull, layerReference);
layerDescriptor.putEnumerated(charIDToTypeID("FTcs"), charIDToTypeID("QCSt"), charIDToTypeID("Qcsa")); // freeTransformCenterState, quadCenterState, QCSAverage
var transformDescriptor = app.executeAction(charIDToTypeID("Trnf"), layerDescriptor, DialogModes.ERROR);
alert(transformDescriptor.getKey());
It contains four keys on the format of typeID's. So I converted the typeID's to charID's and this is what I found:
Index 0 contains the key for: null
Index 1 contains the key for: FTcs - freeTransformCenterScale
Index 2 contains the key for: Ofst - offset
Index 3 contains the key for: Intr - interfaceIconFrameDimmed
There is no data in this descriptor that holds information about the scale or rotation. So the question is: where the heck is it?
The transformation widget and the user-interface must get it from somewhere!
EDIT: Also looked at the descriptor for the smart object - no info there either:
var ref = new ActionReference ();
ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("smartObject"));
ref.putEnumerated (stringIDToTypeID ("layer"), stringIDToTypeID ("ordinal"), stringIDToTypeID ("targetEnum"));
var smartObjectDescriptor = executeActionGet(ref).getObjectValue(stringIDToTypeID ("smartObject"));
(Only contains info about it's contents - ie: the linked document - and nothing about transforms)
Also how can you contact Adobe directly? (like the devs or any devrel -person)
Copy link to clipboard
Copied
When I use the Scriptlistener record a smart object transform the -17.4 degree angle was recorded are you sure your transform contain rotation from 0?
var idTrnf = charIDToTypeID( "Trnf" );
var desc15 = new ActionDescriptor();
var idFTcs = charIDToTypeID( "FTcs" );
var idQCSt = charIDToTypeID( "QCSt" );
var idQcsa = charIDToTypeID( "Qcsa" );
desc15.putEnumerated( idFTcs, idQCSt, idQcsa );
var idOfst = charIDToTypeID( "Ofst" );
var desc16 = new ActionDescriptor();
var idHrzn = charIDToTypeID( "Hrzn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc16.putUnitDouble( idHrzn, idPxl, -45.613444 );
var idVrtc = charIDToTypeID( "Vrtc" );
var idPxl = charIDToTypeID( "#Pxl" );
desc16.putUnitDouble( idVrtc, idPxl, -295.410643 );
var idOfst = charIDToTypeID( "Ofst" );
desc15.putObject( idOfst, idOfst, desc16 );
var idWdth = charIDToTypeID( "Wdth" );
var idPrc = charIDToTypeID( "#Prc" );
desc15.putUnitDouble( idWdth, idPrc, 76.933985 );
var idHght = charIDToTypeID( "Hght" );
var idPrc = charIDToTypeID( "#Prc" );
desc15.putUnitDouble( idHght, idPrc, 76.933985 );
var idAngl = charIDToTypeID( "Angl" );
var idAng = charIDToTypeID( "#Ang" );
desc15.putUnitDouble( idAngl, idAng, -17.402914 );
executeAction( idTrnf, desc15, DialogModes.NO );
Copy link to clipboard
Copied
I've done quite some research on this and I've seen the post from people (like for ex. c.pfaffenbichler ) saying it's impossible to retrieve this data.
That I could not figure it out does not mean someone else might not be able to.
And some stuff may become accessible with future updates.
Unfortunately a feature may be implemented broken right away, see Smart Object Layer Comps assessment via Scripting …
Copy link to clipboard
Copied
There seems to be some problem. I did a Google search and found and thread about it being available in the SDK for smart object layers and text layers but hard to get at ina Photoshop script Ther were able to do it for a text layer but there seems to be a problem with smart objects layers. css - How can I extract a layer's transformation matrix in Photoshop? - Graphic Design Stack Exchang...
Copy link to clipboard
Copied
I do not know Action Manager code but I do know how Actions are recorded. If some settings are not changed from Photoshop's default setting then nothing will be recorded for those setting. Like If you do not change the name a save as then nothing is recorded for file name. If you do not rotate from 0 in a transform than nothing is recorded for angel. If you can not retrieve an angle it may be that three is no rotation that it is 0. I just hack a scripting. Try a transform smart object layer you know that the layers object has been rotated. The one you tried may not have been rotated.
Copy link to clipboard
Copied
You have two options:
1) read events and their arguments... and you will got data like from script listener above. But you are unable keep this data after Photoshop restart. You could save informations into PSD metadata, but if somebody else send PSD to you, you will not have these data.
But if enter into free transform mode and you hit enter without any transform change, you will see transformation data. You can enter in this mode with javascript. But leave this mode is harder. Because JSX usually can't do a lot in transformation mode and text mode.
But hit enterkey should solve it. Anyway I don't know how JSX can send keystroke. But you can run from JSX any EXE file which can do it for you. But you will need synchronize these events.
2) Read PSD as binary file.
In this case, you need first save PSD ... or wrap smart object into linked smart object and save them into temp folder. Read binary data and then undo in PS.
Adobe Photoshop File Formats Specification
Hex Editor Neo has PSD template for structure viewer https://www.hhdsoftware.com/images/screenshots/hex-full-pacific-coloring-scheme-floating-layout.png
Anyway I wish you good luck. Both approaches are f**king hard 😄
Copy link to clipboard
Copied
I am using photoshop-connection npm module, which is conversion of a generator script.
When I fetch the document information via socket, I get this:
There is a "transform" part! Which is - maybe - useable.
Copy link to clipboard
Copied
Does this reads only saved PSD or layers directly inside PS app?
Copy link to clipboard
Copied
It reads memory info from open .psd.
Copy link to clipboard
Copied
I do not know if any of what you show is related the what the op wants. In the past I tried to see if anyone ever posted a way to knows if a placed image was scaled by Photoshop and if it was what it was scaled to. I can see in Photoshop UI the Photoshop has recorded all that information in the PSD. All I need to do is target the smart object layer and uset Ctrl+T and Photoshop populated the transform option bar with all the information. Like it does when you use menu File>Place. When you use "Place" Photoshop may or may not scale the object placed in to fit within canvas. I needed to know the object size so I could scale it to the size I needed it to be. I was never able to fine out a way to retrieve the layers transform information. I use a work around. I simply resized the smart object to 100% in case is was scaled the use the layers bounds to get the size of the smart object. I then scaled the full size object to the size I requited for the collage I was populating. I then positioned the layer and masked the layer to shape.
Here I show a PSD I created and saved I open the Target the smart object I placed the other day. And use Ctrl+T. You see Photoshop shows the layers transform information in the option bar. rotate it back to 0 and scale it back to 100% and show the Layers size.
Copy link to clipboard
Copied
Good news. I solved this problem. Transform points are accesibble from Action Manager code. Download here: Magic scripts for Photoshop
If there is some smart math guy I can add support for perspective. I know how change perspektive, but I don't know exactly what single number means.
Copy link to clipboard
Copied
Thanks Jarda!
Your research is very valuable for me. I didn't know 'transform', 'nonAffineTransform' and 'size' is obtainable via AM code.
Oliver