PhotoshopForums.com Home
Navigate Contact FAQ Search Members
Javascript export layer
Post new topic   Reply to topic    PhotoshopForums.com Forum Index -> Actions and Automation
 See a User Guidelines violation? Please contact us.
Author Message

Jeffrey123

Joined: 18 Dec 2012
Posts: 2



PostPosted: Tue Dec 18, 2012 4:50 am    Post subject: Javascript export layer Reply with quote

Hello,

I need some expert help with a javascript. I have multiple Photoshop files with 2 groups. Group 1 contains adjustments layers, group 2 contains an image. The adjustment layers are channel mix layers wich changes the colors of the product image. Each layer has it's own color code that should be at the end of the each filename. What I want is that the script splits up the product with the adjustment layer into different files. I already have a script that almost works. I don't now a thing about javascript so that's why I need help. The thing that needs to be changed is that the complete bottom group (with the product image) is being exported with every adjustment layer. This is the script I have now:

// 2011; use it at your own risk;
#target photoshop
// check and get back array of selected layer;
checksOut = checkPhotoshop();
if (checksOut == true) {
//app.togglePalettes();
// define document;
var myDocument = app.activeDocument;
// thanks to xbytor for regexp;
var docName = myDocument.name;
var basename = docName.match(/(.*)\.[^\.]+$/)[1];
var docPath = myDocument.path;
var set1 = myDocument.layers[0];
set1.visible = true;
var set2 = myDocument.layers[1];
set2.visible = true;
// psd options;
psdOpts = new PhotoshopSaveOptions();
psdOpts.embedColorProfile = true;
psdOpts.alphaChannels = false;
psdOpts.layers = true;
psdOpts.spotColors = true;
// hide layers;
for (var a = 0; a < set2.layers.length; a++) {
set2.layers[a].visible = false
};
for (var b = 0; b < set1.layers.length; b++) {
set1.layers[b].visible = false
};
// process layers;
for (var c = 0; c < set2.layers.length; c++) {
var layer2 = set2.layers[c];
layer2.visible = true;
for (var d = 0; d < set1.layers.length; d++) {
// show one adjustment;
var layer1 = set1.layers[d];
layer1.visible = true;
// duplicate the image;
var thecopy = myDocument.duplicate (myDocument, true);
thecopy.saveAs((new File(docPath+'/'+"Afbeeldingen"+'/'+basename+"_"+layer1.name+".psd")),psdOpts,true);
thecopy.close(SaveOptions.DONOTSAVECHANGES);
// hide adjustment;
layer1.visible = false;
};
// hide layer;
layer2.visible = false;
};
//app.togglePalettes();
};
////// check if file is eligible for this script //////
function checkPhotoshop() {
var checksOut = true;
if (app.documents.length == 0) {
alert("no documents are open\nplease open a document and try again");
checksOut = false
}
else {
if (app.activeDocument.layers.length != 2) {
alert("the current document does not fit");
checksOut = false
}
else {
if (app.activeDocument.layers[0].typename != "LayerSet" || app.activeDocument.layers[1].typename != "LayerSet") {
alert("the current document does not have two layersets");
checksOut = false
}
}
};
return checksOut
};


This script takes the bottom layer and exports it with the adjustment layer, I want it to take the whole bottom group and export it with each adjustment layer. I hope somebody can help me! Attached are some screenshots of the layers and what the end result should be. Thanks in advance!

/Jeffrey
[/img]
View user's profile Send private message

Auieos

Joined: 29 Jan 2010
Posts: 2019



PostPosted: Tue Dec 18, 2012 8:12 am    Post subject: Reply with quote

Blind leading the blind here.

Have you tried merging the bottom layers in to a single one, turning the document into something the script possibly works with?
View user's profile Send private message

Jeffrey123

Joined: 18 Dec 2012
Posts: 2



PostPosted: Tue Dec 18, 2012 8:18 am    Post subject: Reply with quote

Yes, that's what I have been trying but they want this PSD file like it is, so they can still edit everything. But the script does work when it's one layer. We're talking about a 1000 PSD files, so that's a lot to merge...
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PhotoshopForums.com Forum Index -> Actions and Automation All times are GMT - 6 Hours
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Contact - User Guidelines >

Copyright © 2003-2016. PhotoshopForums.com, iFroggy Network. All Rights Reserved.
Powered by phpBB © phpBB Group. phpBB SEO. Privacy Policy.
We are in no way affiliated with Adobe. Photoshop, Adobe and related marks are registered trademarks of Adobe.
PhotoshopForums.com