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

Would like to automate open stacks as layers + run action. Possible with script??

Explorer ,
Jul 22, 2011 Jul 22, 2011

Copy link to clipboard

Copied

I would like to automate part of my workflow that involves opening stacked images as layers in Ps CS5 and running an PS action that composites the layers and processes the image. Something similar to 'Process Collection' in Bridge CS5 only with my own action instead of merge to HDR/Panorama.

Apparently this is possible with Mac 'Automator' - is there anything I can do in Windows? I don't have any experience with writing scripts, but have friends that can help. Can someone tell me if its possible and point me in the right direction please?

TOPICS
Actions and scripting

Views

15.7K

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

correct answers 1 Correct answer

Guru , Jul 24, 2011 Jul 24, 2011

For the name, I was thinking more along the lines of using the name of the first image in the stack( or top layer name ) as part of the filename.

For the action, I think it depends on the action and how the script is to be used. My tests had images stacks of three images each. The action selects the top layer, inverts, selects the layer below, inverts, selects the layer below and inverts. So it inverts all the layers because it expects there to be three layers. I guess you could script running th

...

Votes

Translate

Translate
Adobe
Community Expert ,
Jul 22, 2011 Jul 22, 2011

Copy link to clipboard

Copied

Photoshop CS5 ships with a Script "Load Files into  Stack" that uses three of Photoshop Stacks Scripts that will load files into a Document as layers and optionally align them. In this forum or PS-Scripting community web other have written scripts to load  files into a stack and align them as a strip by expanding the canvas and then moving the newly add layer into the expanded area.  Auto Collection I believe is what you wrote about seems to be listed the Bridge  preferences in startup scripts.

"Load files into a stack" is not a plug in script so you can not record its use in an action and bypass its dialog. However you may be able to do what you want in two stages. "Load Files into stack"  followed by a script that you write that will process all the layers. Targeting layer after layer and do your action for each targeted layer.

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
Guru ,
Jul 22, 2011 Jul 22, 2011

Copy link to clipboard

Copied

Stilesy911 wrote:

Something similar to 'Process Collection' in Bridge CS5 only with my own action instead of merge to HDR/Panorama.

If you want to work from Bridge you can select your images then choose Tools-Photoshop-Load Files into Photoshop Layers. That will load the selected files into one Photoshop document. You can then run your action.

It may be possible to automate your entire workflow but we would need more details about what you want done.

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
Explorer ,
Jul 22, 2011 Jul 22, 2011

Copy link to clipboard

Copied

Thanks for your help. I should clarify that I would like to automatically process multiple stacks. So a script would need to..

1) find first stack

2) open as layers

3) run PS action

4) save and close (as psd preserving layers)

5) find next stack, etc

I'm already using open as layers (LR3) and processing with the PS action. While this semi automatic approach is ok, the actions take a while to work through and it would better if I was free to do something else  (such as help my wife with our newborn).

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 ,
Jul 22, 2011 Jul 22, 2011

Copy link to clipboard

Copied

I do not use LR so I'm having a bit of a problem understanding where these stacks are created or are coming from.  You wrote something about LR open as layers. Since LR is not a image editor that supports layers LR must be passing a collection or an image list to Photoshop to have Photoshop load the images into a document as layers in its layers stack. Any way this sounds like how you create a stack so you can process it with your action.  So I don't understand what you mean by find next stack.  As far as I know LR does not have scripting support.  So I don't understand how your stack  processing can work in LR where you loop through stacks and process them with a Photoshop Action.  I know LR can use Photoshop but I know little about LR output module and its features can it loop through collections of images and have Photoshop stack them into layers and run an action or a script?   Describing your stack concept in more detail here may help.

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
Explorer ,
Jul 23, 2011 Jul 23, 2011

Copy link to clipboard

Copied

I'm managing my workflow with Lightroom 3 at the moment. In Lightroom I can automatically stack images (by capture time). I then manually select two or three images and open as layers in Photoshop CS5. Then run my ps processing action, save and close and move on to the next stack. Lightroom doesn't support layers however you can send the files to Photoshop as layers (same as Bridge) and reimport the file as a layered psd doc.

Just ignore the LR comment though, because as you said, it doesn't support script. If a script is possible, then I would use Bridge to do the job - ie stack images and open the stacks as layers in Photoshop.

Bridge CS5 has the Batch or Image Processor tools that open images, run actions, save and close etc. This is what I need - only with the ability to recognise Stacks and open the Stacks as layers documents.

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 ,
Jul 23, 2011 Jul 23, 2011

Copy link to clipboard

Copied

Stilesy911 wrote:

Bridge CS5 has the Batch or Image Processor tools that open images, run actions, save and close etc. This is what I need - only with the ability to recognise Stacks and open the Stacks as layers documents.

As I wrote I don't understand your concept of what constitutes a stack.   How do you recognize one. Perhaps if you give that information we could give you an answer as to weather that could be scripted or not. What make a stack? What is a stack made of?  Is a stack a folder of files or sub folders in a tree? How do you know a stack?

The Bridge uses Photoshop uses its automate batch feature and Script Image Processor through a Bridge talk scripting interface.  You may or may not need to use the bridge. The fist thing you need do is to figure out if the Bridge or Photoshop can be scripted to do what you do see and process what your see are stacks.

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
Explorer ,
Jul 24, 2011 Jul 24, 2011

Copy link to clipboard

Copied

In Bridge (and Lightroom) a 'Stack' is used to organise similar photos. I just keeps the files together - it doesn't affect what's in the file.

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 ,
Jul 24, 2011 Jul 24, 2011

Copy link to clipboard

Copied

I see now. I do not use all features of Photoshop and Bridge and have always organized files in folders  I created new Folders for each photo session. If a group of images in a session were for a panorama  or a group of images were related in some special way I would group the int sub directories in the session.  Now I see there is Adobe Stack concept.  At first glance it seem to have the same problem I have with Sub folders there no easy way to have an image in more then one group other then file system shortcuts which you can create in windows file explorer but not in the Bridge itself.  Now that I know about Adobe Stacks(groups)  I'll stick with how I've been doing groups.  For I can see then in other applications like Windows File explorer, Photoshop etc.  LR has collection that allows you to create groups of images any image may be in more then one collection yet there is only one copy of the image. Must be a database thing.  I don't have LR.

Since you create your Stacks(groups) and name these stacks in Bridge and the Bridge see them as stacks I quite sure what you want to do can be done with Bridge Scripting. Bridge Scripting is different then Photoshop Scripting I have not looked into Bridge scripting other have and may be able to help you. Bridge Scripting can also communicate with Photoshop Scripting through some interface I think is named Bridge Talk.

I also saw in Bridge Help there is an Auto Collection Script supplied for automating HDR and panoramas

The Auto Collection CS5 script in Adobe Bridge assembles sets of images into stacks for processing as high dynamic range (HDR) or panoramic composites in Photoshop CS5. The script collects images into stacks based on capture time, exposure settings, and image alignment. Timestamps must be within 18 seconds for the Auto Collection script to process the photos. If exposure settings vary across the photos and content overlaps by more than 80%, the script interprets the photos as an HDR set. If exposure is constant and content overlaps by less than 80%, the script interprets the photos as being part of a panorama.

Note: You must have Adobe Bridge with Photoshop CS5 for Auto Collection CS5 to be available.
  1. To enable the Auto Collection CS5 script, choose Edit > Preferences (Windows) or Adobe Bridge CS5.1 > Preferences (Mac OS).
  2. In the Startup Scripts panel, select Auto Collection CS5, and then click OK.
  3. Select a folder with the HDR or panoramic shots, and choose Stacks > Auto-Stack Panorama/HDR.
  4. Choose Tools > Photoshop > Process Collections In Photoshop to automatically merge them and see the result in Adobe Bridge.
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
Guru ,
Jul 23, 2011 Jul 23, 2011

Copy link to clipboard

Copied

In Bridge, with javascript, you can get a reference to the image stacks in a window using app.document.stacks. So I think what you want can be scripted in javascript which will run on Windows.

The Bridge scripting experts are at http://forums.adobe.com/community/bridge/bridge_scripting. So you might want to post your request there.

Or I will try to help if you will clarify your workflow.

Do you want to start the process from Bridge or Photoshop?

Do you want it to process all image stacks in folder or just the selected ones?

The script should load all the image in the image stack into one layered Photoshop document, right?

Then run your action( will need the name of the action and action set ) then save as PSD.

Where do you want the psd saved and what filename?

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
Explorer ,
Jul 24, 2011 Jul 24, 2011

Copy link to clipboard

Copied

Hi Michael

Thanks, that's quite helpful. To clarify my workflow..

Do you want to start the process from Bridge or Photoshop?

Would like to start in Bridge.

Do you want it to process all image stacks in folder or just the selected ones?

Would like to process all the 'stacks' in the folder (one stack at a time though)

The script should load all the image in the image stack into one layered Photoshop document, right?

Correct - each 'stack' consists of 2+ similar images (different exposures etc for hdr/blending). The need to be opened into one photoshop document as layers for the ps action.

Then run your action( will need the name of the action and action set ) then save as PSD.

Where do you want the psd saved and what filename?

I'll probably want to save the processed files into a folder on my desktop.

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
Explorer ,
Jul 24, 2011 Jul 24, 2011

Copy link to clipboard

Copied

I have moved this thread to Bridge Scripting. Please see http://forums.adobe.com/thread/881342 for further discussion.

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 ,
Jul 24, 2011 Jul 24, 2011

Copy link to clipboard

Copied

Just to see if this can be scripted in javascript I created this quick and dirty Bridge script. It will process all image stacks in the open window of Bridge and save the psd to the desktop.

// this is a Bridge script, run from ESTK with Bridge as the target app

var stacks = app.document.stacks;
var stackCount = stacks.length;
for(var s = 0;s<stackCount;s++){
     var stackFiles = getStackFiles( stacks );
     if(stackFiles.length> 1){
          var bt = new BridgeTalk;
          bt.target = "photoshop";
          var myScript = ("var ftn = " + psRemote.toSource() + "; ftn("+stackFiles.toSource()+");");
          bt.body = myScript;
          bt.onResult = function( inBT ) {myReturnValue(inBT.body); }
          bt.send(500);
     }
}
function getStackFiles( stack ){
     var files = new Array();
     for( var f = 0; f<stack.thumbnails.length;f++){
          files.push(stack.thumbnails.spec);
     }
     return files;
};
function myReturnValue(str){
     res = str;
}
// don't have comments in the psRemote function
function psRemote(stackFiles){
     var loadLayersFromScript = true;
     var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets");
     var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts");
     var strFile2Stack = "Load Files into Stack.jsx";
     var ipFilePath = app.path + "/" + strPresets + "/" + strScripts + "/" + strFile2Stack;
     var ipFile = new File (ipFilePath);

     $.evalFile( ipFile );
     loadLayers.intoStack(stackFiles);
     app.doAction ('Action 2', 'test');
     var saveFile = new File('~/desktop/'+app.activeDocument.name+'.psd');
     app.activeDocument.saveAs(saveFile);
     app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}

I am sure that the members of the Bridge Scripting forum can come up with something better but this does work for me with CS5.

JJMack, you can also create a image stack in Bridge by selecting a group of images then from the context menu choose Stack-Group as Stack.

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
Valorous Hero ,
Jul 24, 2011 Jul 24, 2011

Copy link to clipboard

Copied

That's great Mike, but it will overwrite the previous created file and only one psd will remain.

(IE: They all have the same name)

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 ,
Jul 24, 2011 Jul 24, 2011

Copy link to clipboard

Copied

Yes, it is not ideal. I wasn't sure how to handle the save name so I just left that to the default name( and it overwrites because of that ). I also don't like how the action is hardcoded. But it does show that this workflow can be scripted. I'm sure it can be tweaked to create something more useful.

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
Valorous Hero ,
Jul 24, 2011 Jul 24, 2011

Copy link to clipboard

Copied

That's very true, maybe something on the line of:

var saveFile = new File('~/desktop/'+(new Date().getTime().toString())+'.psd');


I was also wondering about the action, as it is now it it only run once, but does it need to be run on each layer?

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 ,
Jul 24, 2011 Jul 24, 2011

Copy link to clipboard

Copied

For the name, I was thinking more along the lines of using the name of the first image in the stack( or top layer name ) as part of the filename.

For the action, I think it depends on the action and how the script is to be used. My tests had images stacks of three images each. The action selects the top layer, inverts, selects the layer below, inverts, selects the layer below and inverts. So it inverts all the layers because it expects there to be three layers. I guess you could script running the action on all the layers but depending on the workflow that might not be ideal.

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
Explorer ,
Aug 06, 2011 Aug 06, 2011

Copy link to clipboard

Copied

Hi Michael

I've been trying to learn Javascript all weekend and my head is spinning.

Your script seems to do a great job of sending the stacks from Bridge to Photoshop as layers - but the second part of the script doesn't seem to be working. I'm guessing because I need to add a comment to psRemote.

************************************

// don't have comments in the psRemote function

function psRemote(stackFiles){

     var loadLayersFromScript = true;

     var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets");

     var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts");

     var strFile2Stack = "Load Files into Stack.jsx";

     var ipFilePath = app.path + "/" + strPresets + "/" + strScripts + "/" + strFile2Stack;

     var ipFile = new File (ipFilePath);

     $.evalFile( ipFile );

     loadLayers.intoStack(stackFiles);

     app.doAction ('Action 2', 'test');

     var saveFile = new File('~/desktop/'+(new Date().getTime().toString())+'.psd');

     app.activeDocument.saveAs(saveFile);

     app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

*************************************

What comments do I need to add to psRemote so that the script runs my action "Timsblend1" then saves as closes.

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
Valorous Hero ,
Aug 07, 2011 Aug 07, 2011

Copy link to clipboard

Copied

You need to amend the doAction line with your action details.

doAction("ActionName","ActionSet");

N.B. Both the action name and action set name are case sensitive.

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 ,
Aug 07, 2011 Aug 07, 2011

Copy link to clipboard

Copied

Paul is right, you need to edit the doAction line. You can also remove the line  $.evalFile( ipFile );

toSource() removes line breaks and other formatting chars like tabs and extra spaces. Because the line breaks are removed line comments ( comments that start with // ) have the effect of commenting out the remainder of the function thus breaking the script. But because the toSource step in done in the Bridgetalk message it is not obvious. The line about comments was just a reminder not to use line comments.

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
Explorer ,
Aug 10, 2011 Aug 10, 2011

Copy link to clipboard

Copied

Thanks again Paul and Michael. I had the script running really well yesterday morning and saved it without making any changes. However, this morning it has stopped working completely. Something is stopping the send to photoshop bit as I can't get the stacks to open at all. The only thing that I can think that has changed was an automatic windows update.

The script is below - would you mind checking it for me? Is there something I'm missing?

I'm running it in Extend Toolkit set to Bridge CS5 Main Engine.


var stacks = app.document.stacks;
var stackCount = stacks.length;
for(var s = 0;s<stackCount;s++){
var stackFiles = getStackFiles( stacks );
if(stackFiles.length> 1){
var bt = new BridgeTalk;
bt.target = "photoshop";
var myScript = ("var ftn = " + psRemote.toSource() + "; ftn("+stackFiles.toSource()+");");
bt.body = myScript;
bt.onResult = function( inBT ) {myReturnValue(inBT.body); }
bt.send(500);
}
}
function getStackFiles( stack ){
var files = new Array();
for( var f = 0; f<stack.thumbnails.length;f++){
files.push(stack.thumbnails.spec);
}
return files;
};
function myReturnValue(str){
res = str;
}
function psRemote(stackFiles){
var loadLayersFromScript = true;
var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets");
var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts");
var strFile2Stack = "Load Files into Stack.jsx";
var ipFilePath = app.path + "/" + strPresets + "/" + strScripts + "/" + strFile2Stack;
var ipFile = new File (ipFilePath);
loadLayers.intoStack(stackFiles);
app.doAction ('hdr3', 'timsactions');
var saveFile = new File('~/desktop/'+(new Date().getTime().toString())+'.psd');
app.activeDocument.saveAs(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}

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
Explorer ,
Aug 10, 2011 Aug 10, 2011

Copy link to clipboard

Copied

PS: Error is Execution Finished. Result: true

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 ,
Aug 10, 2011 Aug 10, 2011

Copy link to clipboard

Copied

Sorry, bad advice on my part. Don't know what I was thinking but you need to restore the evalfile line I said to remove.

function psRemote(stackFiles){
var loadLayersFromScript = true;
var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets");
var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts");
var strFile2Stack = "Load Files into Stack.jsx";
var ipFilePath = app.path + "/" + strPresets + "/" + strScripts + "/" + strFile2Stack;
var ipFile = new File (ipFilePath);
$.evalFile( ipFile );
loadLayers.intoStack(stackFiles);
app.doAction ('hdr3', 'timsactions');
var saveFile = new File('~/desktop/'+(new Date().getTime().toString())+'.psd');
app.activeDocument.saveAs(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}

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
Explorer ,
Aug 11, 2011 Aug 11, 2011

Copy link to clipboard

Copied

FANTASTIC!! It works again. Its wierd that it was working yesterday without the $Eva . Ah well. Thanks so much

Michael.

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
Explorer ,
Oct 09, 2013 Oct 09, 2013

Copy link to clipboard

Copied

Hello,
After a long search I found this thread. And it works perfectly ... But unfortunately not in Bridge CS6 😞

I use Windows7 64 and CS6. When I run the script from the Extended Script Toolkit, everything works great.

Then I saved the script in the Bridge folder "startup scripts". At the start of Bridge I get the following error message:

"Error in C: \ Users \ ... \ AppData \ Roaming \ Adobe \ Bridge CS6 \ Startup
Scripts \ Stack Batch.jsx
Line 1: var = app.document.stacks stacks;
undefined is not an object "

Bridge and then starts the script is not enabled.

I know this discussion is a bit older. But hopefully someone can help me?

Thanks for any help
kai-

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