Skip to main content
Inspiring
December 9, 2010
Question

Actions Vs Scripts

  • December 9, 2010
  • 2 replies
  • 1913 views

Has anyone tried out to see if scripting is faster than actions. - Yes I'm aware that all depends on how the script is written,  but I was just wondering in having to get several hundred images processed would a script be faster than an action (to do the same job)  Or are they doing exactly the same thing. Is there anything going on under the hood that I don't know about that would cause one to process faster than the other?

This topic has been closed for replies.

2 replies

Muppet_Mark-QAl63s
Inspiring
December 10, 2010

Is there anything going on under the hood that I don't know about that would cause one to process faster than the other?

Well there is your action's playback options but I guess you already know about those.

Inspiring
December 10, 2010

Muppet Mark wrote:

Well there is your action's playback options but I guess you already know about those.

It's my understanding that the playback options affect both actions and scripts. Yes setting the playback option to accelerated will speed things up but does so for both. So it doesn't give an advantage to one over the other. Or I guess I should say it gives the same advantage to both.

Muppet_Mark-QAl63s
Inspiring
December 10, 2010

It's my understanding that the playback options affect both actions and scripts. Yes setting the playback option to accelerated will speed things up but does so for both. So it doesn't give an advantage to one over the other. Or I guess I should say it gives the same advantage to both.

Now I was thinking that this may slow down your action but Script would be unaffected (I've not so much as tested this as you can probably tell). I can't recall seeing any changing of playback options with script to make sure accelerated is utilised… did I miss something? (Just been and checked the manual n yes I did) Doh!… still a dammed muppet… never learn…

Tom Ruark
Inspiring
December 9, 2010

Scripting is a layer on top of actions. I don't see how scripting could be faster. Scripting gets you logic that actions cannot do.

Participant
December 11, 2010

Correct me if I am wrong...

My uderstanding of this is differnt.

I have observed that scripts like:

// enable double clicking from the Macintosh Finder or the Windows Explorer

#target photoshop

// in case we double clicked the file
app.bringToFront();

var fgColor = new SolidColor();
fgColor = app.foregroundColor;

var fgRGBColor = fgColor.rgb;
alert("Red:" + fgRGBColor.red + " Green:" + fgRGBColor.green + " Blue:" + fgRGBColor.blue);

work/execute directly no PS and are much faster compared to scripts like those generated by Script Listner :


// =======================================================

#target photoshop

var id30 = charIDToTypeID( "setd" );
    var desc9 = new ActionDescriptor();
    var id31 = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var id32 = charIDToTypeID( "Lyr " );
        var id33 = charIDToTypeID( "Ordn" );
        var id34 = charIDToTypeID( "Trgt" );
        ref6.putEnumerated( id32, id33, id34 );
    desc9.putReference( id31, ref6 );
    var id35 = charIDToTypeID( "T   " );
        var desc10 = new ActionDescriptor();
        var id36 = charIDToTypeID( "Nm  " );
        desc10.putString( id36, "Set Opacity" );
    var id37 = charIDToTypeID( "Lyr " );
    desc9.putObject( id35, id37, desc10 );
executeAction( id30, desc9, DialogModes.NO );

Such scripts tend to trigger necessary actions instead of working directly.

Inspiring
December 11, 2010

The ActionManager API is the low level API in PS.

The code

fgColor = app.foregroundColor;

actually does get mapped onto the equivalent of

  var ref = new ActionReference();
  ref.putEnumerated(charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
  var desc = executeActionGet(ref);
  fgClr = desc.getObjectValue(charIDToTypeID('FrgC'));

The scripting APIs are built on top of the same automation framework. In JS, that DOM layer is thinner/faster than VB or AS. But bypassing the DOM will, in general, result in better performance. It's just a lot more difficult to write and maintain.