Skip to main content
Inspiring
February 10, 2017
Question

Once and for all: Is it impossible to retrieve the angle and scale of a Smart Object?

  • February 10, 2017
  • 5 replies
  • 3111 views

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)

This topic has been closed for replies.

5 replies

Jarda Bereza
Inspiring
May 7, 2017

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.

oliverIntergrafika
Inspiring
May 7, 2017

Thanks Jarda!

Your research is very valuable for me. I didn't know 'transform', 'nonAffineTransform' and 'size' is obtainable via AM code.

Oliver

Jarda Bereza
Inspiring
February 10, 2017

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.

Photoshop: Is there way how to read deformations values applied on Smart Object via a Script? | Photoshop Family Custome…

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 :-D

2016-04-27_222733.png

oliverIntergrafika
Inspiring
February 11, 2017

I am using photoshop-connection npm module, which is conversion of a generator script.

photoshop-connection

When I fetch the document information via socket, I get this:

There is a "transform" part! Which is - maybe - useable.

Jarda Bereza
Inspiring
February 11, 2017

Does this reads only saved PSD or layers directly inside PS app?

JJMack
Community Expert
Community Expert
February 10, 2017

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.

JJMack
c.pfaffenbichler
Community Expert
Community Expert
February 10, 2017

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 …

Photoshop JavaScript Bug: smartObject’s compID returns nonsense | Photoshop Family Customer Community

JJMack
Community Expert
Community Expert
February 10, 2017

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 Exchange

JJMack
JJMack
Community Expert
Community Expert
February 10, 2017

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

JJMack