|
Author |
Message |
Jeffrey123
Joined: 18 Dec 2012
Posts: 2
|
Posted: Tue Dec 18, 2012 4:50 am Post subject: Javascript export layer |
|
|
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] |
|
|
|
|
Auieos
Joined: 29 Jan 2010
Posts: 2019
|
Posted: Tue Dec 18, 2012 8:12 am Post subject: |
|
|
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? |
|
|
|
|
Jeffrey123
Joined: 18 Dec 2012
Posts: 2
|
Posted: Tue Dec 18, 2012 8:18 am Post subject: |
|
|
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... |
|
|
|
|
|