Go Back   RetouchPRO > Tools > Software > Photoshop Scripting
Register Blogs FAQ Site Nav Search Today's Posts Mark Forums Read

Photoshop Scripting Learning and sharing for all platforms

Looping script with new parameters

Thread Tools
Old 09-01-2015, 06:59 AM
G>> G>> is offline
Junior Member
Join Date: Sep 2015
Posts: 1
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.
Reply With Quote top
Old 09-02-2015, 07:55 AM
klev klev is offline
Senior Member
Join Date: Jun 2010
Posts: 954
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.
Reply With Quote top

  RetouchPRO > Tools > Software > Photoshop Scripting

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Photoshop: Targeted layer visibility toggle script infinityspiral Software 0 11-08-2013 02:50 PM
One script to export graphics to mobile platforms johnmford2 Photoshop Scripting 0 10-25-2013 11:53 AM
Photoshop: can't select workspace cs6 with script manager ON mantra Software 3 11-05-2012 03:40 AM
Photoshop: is there a way to record a script or convert ? mantra Software 7 03-30-2012 09:55 AM
Photoshop: is there a script to fit crop ? mantra Software 6 03-13-2012 02:42 AM

All times are GMT -6. The time now is 02:38 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
Copyright © 2016 Doug Nelson. All Rights Reserved