Announcement

Collapse
No announcement yet.

Looping script with new parameters

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Looping script with new parameters

    I'm trying to make this script working in a loop and change parameters in each new loop:

    var layerRef = app.activeDocument.artLayers.getByName("1");
    layerRef.visible = true;

    function saveJPEG( doc, saveFile, qty ) {
    var saveOptions = new JPEGSaveOptions( );
    saveOptions.embedColorProfile = true;
    saveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
    saveOptions.matte = MatteType.NONE;
    saveOptions.quality = qty;
    doc.saveAs( saveFile, saveOptions, true );
    }
    saveJPEG( app.activeDocument, new File('~/Desktop/1.jpg'), 10 );

    The script is making later "1" visible and than save it in to jpeg as "1.jpg". In second loop I need it to make layer 2 visible (layer 1 is still visible - layers are blending) and save it as 2.jpeg. In third loop: layer 3 and save file 3.jpeg, ect...

    Thank you.
    G>>>

  • #2
    Re: Looping script with new parameters

    I need to check what it returns if no layer exists with that name. I'm assuming you use a variable number of layers. Assuming you follow that naming convention, this should work. It's not robust. There are many many things that could fail silently.

    I can tell you how to get that working if you tell me how you want the loop to terminate. Are you going through the same number of layers using that same naming convention each time? I don't know a way to iterate through all layers top to bottom or bottom to top. I just looked at photoshop's api reference to see if it has any direct way to traverse the layer stack. It would be sensible, but I don't see it.

    Comment

    Related Topics

    Collapse

    • infinityspiral
      Targeted layer visibility toggle script
      by infinityspiral
      First post here so sorry if this isn't in the right section. I wrote a few scripts for Photoshop that make my workflow a little easier. The script will take the currently selected layer/group and make it hidden. It also marks it with a "[T]" for toggle. Like this:

      Code:
      Layer0
      ...
      11-08-2013, 03:50 PM
    • Spittle
      Possible to save layers out to 16bit tiff or exr
      by Spittle
      Any idea how I can do this?

      So that each file will be named exactly as per the layer name and preserve transparency.
      04-16-2016, 02:26 AM
    • jjwithers
      Layer Comps to PNG without Numeric Prefix?
      by jjwithers
      I'm going to be saving thousands of layer comps out to PNGs from a series of PSD files and i recently noticed that the script adds a numbered prefix to the name of the files. I do not want this number. Is there any way to run the script without the prefix?
      The file names will have to be specific...
      10-04-2010, 11:56 PM
    • moiremusic
      script to capture layer names...
      by moiremusic
      Has anyone ever heard of a script that takes the names of all the layers and layer sets and puts them in a text file (or something else that would let me take it elsewhere, like a text layer or clipboard)?

      Scripting is a little over my head, but such capability would be quite useful to...
      06-21-2005, 06:58 PM
    • Sequitur
      Script to find/replace text in layer names?
      by Sequitur
      I'm looking for a script that can do a standard text "find and replace" of group names and layer names within photoshop. I'm not sure if this is actually doable, but it would be helpful if anyone knows of such a routine. I'm working with documents that have 1000+ layers that need to conform...
      09-16-2008, 01:39 PM
    Working...
    X