Skip to main content
@MNiessenPhoto
Legend
January 15, 2020
Question

Generate image assets from layers - not working with multiple files and droplet

  • January 15, 2020
  • 4 replies
  • 4972 views

Hi,

 

I'm activating the generation of image assets from layers in Photoshop 2020 (21.0.2, on Windows) and I encounter a couple of issues:

 

1) If I close the file in the action, assets are not generated because the file is closed before that can be done. I've tried inserted a pause in the action to give it time, before closing the file, but it doesn't help, since the image asset generator is only activated after the action has played completely. My current workaround is to simply close the file manually, not from the action.

 

2) The second issue is most likely related to the first one... I created a droplet to run that action, but if I drop multiple files on it, though the action runs without failing on all images, the image assets is actually only activated for the last file, and thus the assets folder is created only for that one. The only way to make it work currently is to drop an image on the droplet, wait a few seconds for the assets folder to be generated, then do the same with the second image, and so on... Once again, slowing or pausing the action doesn't help at all.

 

Does anyone have a solution to this issue, so I can automate it completely, without having to feed one image at a time?

 

Kind regards,

Michael

This topic has been closed for replies.

4 replies

Stephen Marsh
Community Expert
Community Expert
January 16, 2020

For the record, the dependency on the action can be removed with the following edit to the previous script:

 

 

for (var i = 0; i < app.documents.length; i++) {
    app.activeDocument = app.documents[i];
        var idAdobeScriptAutomationScripts = stringIDToTypeID( "AdobeScriptAutomation Scripts" );
        var desc99 = new ActionDescriptor();
        var idjsNm = charIDToTypeID( "jsNm" );
        desc99.putString( idjsNm, """Image Assets""" );
        executeAction( idAdobeScriptAutomationScripts, desc99, DialogModes.NO );
    // Adjust value as required for quantity of open docs
    $.sleep(1000);
};
alert('Ensure that all assets have been saved before closing the active documents!');

 

 

Stephen Marsh
Community Expert
Community Expert
January 15, 2020

Try the following script. Open all images into Photoshop with appropriate layer names to trigger Generate Image Assets. Two things to note:

 

1. You need to create an action set and action with a single step to "Generate Image Assets" and use that name in the script (or name your action set and action as per the original script).

 

2. You may need to increase the sleep value to give the script time to loop through all open files.

 

 

for (var i = 0; i < app.documents.length; i++) {
    app.activeDocument = app.documents[i];
    // Change the action and set as required
    app.doAction("Generate On", "Generate Image Assets.atn");
    // Adjust value as required for quantity of open docs
    $.sleep(1000);
};
alert('Ensure that all assets have been saved before closing the active documents!');

 

 

Once you have confirmed that all assets have been generated, you can close down all open documents in one go, with or without saving.

@MNiessenPhoto
Legend
January 16, 2020

Thank you for this solution, which does work.

My ultimate goal, however, is to export from Lightroom and open the files with the droplet.

Currently, I just export files from Lightroom to my droplet one by one, but it would be great if I could select multiple ones and export them together.

I could certainly export to Photoshop, so they are open, then run your script; it would help, though the underlying issue of assets not being generated from the droplet would still not be resolved.

Regards,

Michael

Photo-editing (Ps/Lr/LrC) and photography workshops &amp; one-on-one training (off- and online)
Stephen Marsh
Community Expert
Community Expert
January 16, 2020

My pleasure, as a fellow end-user, there is only so much that I can do...

 

I would suggest that you make a bug report or feature request at the feedback site:

 

https://feedback.photoshop.com/photoshop_family/categories/photoshop_family_photoshop

Stephen Marsh
Community Expert
Community Expert
January 15, 2020

With Photoshop 2019, I get an error that the script is not available when running the inserted menu command for Generate: Image Assets from a Batch or the Image Processor or Image Processor Pro scripts.

 

I wanted to test what happens when an action plays another action...

@MNiessenPhoto
Legend
January 15, 2020

Thanks for your answer!

 

"With Photoshop 2019, I get an error that the script is not available..."

Actually, the same happens if I use the droplet with one image, close the file manually then run the droplet again. I have to do one picture at a time but leave all the files open, and close then all at the end. Otherwise I have to restart PS.

 

"I wanted to test what happens when an action plays another action..."

Maybe it would help in your case 🤞

For me though, it didn't. That's one of the first things I hoped might help, but unfortunately it doesn't.

 

Regards,

Michael

Photo-editing (Ps/Lr/LrC) and photography workshops &amp; one-on-one training (off- and online)
Stephen Marsh
Community Expert
Community Expert
January 15, 2020

My case is your case, I have no personal need to do this :]

 

I also tried a script to apply the generate action to all open documents, but it did not work, only one file had generate ticked...

 

If I manually cycle between all open files and run the action, it works for all files.

 

 

JJMack
Community Expert
Community Expert
January 15, 2020

When you have a problem with an action its always best if you post your actions so we can analyze what the action is doing.

JJMack
@MNiessenPhoto
Legend
January 15, 2020

Hi,

Thank for answering!

I didn't include the action because, as mentioned, it isn't a problem with the whole action, which runs without failing and all the other steps give the expected result 😉 This is specifically an issue with generating image assets.

 

Actually, an action that only activates image assets, and nothing else, will have exactly the same problem (yes, I've tried 😉) :

1) if besides activating image assets, the action should close the file, it runs without error and the file is closed, but no assets are created (no time).

2) if there is only that single step (image assets) and you create a droplet, it will work fine if you drop a single file on the droplet. If you drop 2 or more files, it is activated and an assets folder will be created only for the last one, despite all the files staying open.

 

Regards,

Michael

 

Photo-editing (Ps/Lr/LrC) and photography workshops &amp; one-on-one training (off- and online)