• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Actions Vs Scripts

Engaged ,
Dec 09, 2010 Dec 09, 2010

Copy link to clipboard

Copied

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?

TOPICS
Actions and scripting

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Adobe Employee ,
Dec 09, 2010 Dec 09, 2010

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 10, 2010 Dec 10, 2010

Copy link to clipboard

Copied

Scripting is a layer on top of actions. I don't see how scripting could be faster.

I’m not sure this is the case, but does hiding the Panels not improve the performance of some Actions/Scripts?

(Because the various Panels’ previews don’t get updated, I suspect.)

And that’s one thing that’s not in itself Action-able (as far as I know) – of course one could just hide the Panels before running the Batch, but with a Script that could be part of the operation.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Dec 10, 2010 Dec 10, 2010

Copy link to clipboard

Copied

I think Tom is right. The best one could hope for is that a script would be as fast as an action becasue of the added layer. I have not done any testing but we know that some tasks such as working with a document that has lots of layers is much slower using the DOM than actions.

I would say use actions where you can and scripts where you need the logic

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 10, 2010 Dec 10, 2010

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 10, 2010 Dec 10, 2010

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 10, 2010 Dec 10, 2010

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Dec 10, 2010 Dec 10, 2010

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 10, 2010 Dec 10, 2010

Copy link to clipboard

Copied

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…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 10, 2010 Dec 10, 2010

Copy link to clipboard

Copied

Actions and Scripts can also work together. Actions can use scripts from menu "File>Scripts>Script" and "File>Automate>Script" and scripts can do actions

doaction(Action Set Name, Action).    For me Action are quick and easy to develop where scripting is labor intensive for I lack knowledge and can not type though I've been using computers and keyboards for decades.

I have put together a little package on crafting actions which includes some script I created the help the action create put a little logic in their actions. http://www.mouseprints.net/old/dpr/JJMacksCraftingActions.zip this package includes:

Action Actions Palette Tips.txt

Action Creation Guidelines.txt

Action Dealing with Image Size.txt

Action Enhanced via Scripted Photoshop Functions.txt

CraftedActions.atn Sample Action set includes an example Watermarking action

Sample Actions.txt Photoshop CraftedActions set saved as a text file. This file has some additional comments I inserted describing how the actions work.

12 Scripts for actions

The sample watermarking action uses one of my run twice script that acts like a save and restore for actions.  The actions uses the script to save the document dpi print size. Then the action changes the print dpi size  so it can add watermarks the are a good size for the resized document.  Once the watermarks are added the action runs the script a second time and this time the script restores the document to it original print size which also resizes the added watermarks. The Action&Script work well on just about any size image.  Because the Action add some layer style and the image is never resampled if one tries to watermark a very small image the watermarks will not be readable and the layer style would be too large for they can not be recorded in a relative way.

Watermark Example:

http://www.mouseprints.net/old/dpr/WM900x600.jpg

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines