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

Script - create .jpg - using various (visible) layers

Community Beginner ,
Jul 18, 2013 Jul 18, 2013

Hello

I have trubble creating a script for Photoshop CS 5.

I have got a .PSD document with several layers, some of which are visible, some are invisible.

I want the script to make the selected layer visible (only one layer is selected). Than i want it to create a .jpg including all visible Layers. And I want the .jpg named after the name of the document with the addition of 01 (for example: Document named 123.psd, so create 12301.jpg)

After that i need the script to make the selected layer invisible. I than want to automatically select the next layer below (or above, doesn't matter), make that one visible and create a .jpg including all visible layers, like before. This .jpg file needs to add the suffix 02 (so create a file 12302.jpg).

Than make selected layer invisible, select the next layer and repeat.

I found a matching script from 6 years ago on the internet. It works, but painfully slow. I think it is because I am using Photoshop CS 5 and that script was written for a previous version.

Here is the script I am using right now:

var datRef = activeDocument;

var pfad = Folder.selectDialog("Waehle eine Zielordner");

exportOptionsSaveForWeb = new ExportOptionsSaveForWeb(); 

exportOptionsSaveForWeb.quality = 60; 

exportOptionsSaveForWeb.includeProfile = true; 

exportOptionsSaveForWeb.optimised = true; 

exportOptionsSaveForWeb.format = SaveDocumentType.JPEG; 

for( var einEbene = 0; einEbene< datRef.artLayers.length; einEbene++) {

    for( var ebenTemp = 0; ebenTemp < datRef.artLayers.length; ebenTemp++) {

        if( datRef.artLayers[ebenTemp].name != "Hintergrund"){

            datRef.artLayers[ebenTemp].visible = false;}

    }

    

    savedState = datRef.activeHistoryState;

    

    if( datRef.artLayers[einEbene].name != "Hintergrund"){

        datRef.artLayers[einEbene].visible = true;

        var saveFile = new File(pfad + "/" + datRef.artLayers[einEbene].name + ".jpg");

        datRef.exportDocument (saveFile, ExportType.SAVEFORWEB, exportOptionsSaveForWeb);}

        

    datRef.activeHistoryState = savedState;

}

If you can help me, run that script faster, or create a script that does what I described propperly, it'll be mutch appreceated.

TOPICS
Actions and scripting
809
Translate
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
Guru ,
Jul 18, 2013 Jul 18, 2013
LATEST

I don't think it's because you have CS5. Scripts that work with layers like this can be slow. Sometimes very slow Depending on the number of layer in the document and the document size. Exporting the files using SaveForWeb may also be a speed problem with large documents.

Translate
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