Converting Photoshop Script
Posted: Thu Mar 22, 2012 4:05 pm
Please Help!
I have a script that works great when ran manually. I want to use it in a switch flow. This script creates Tifs from adjustment layers in the open document. Is it possible to have all of these new tifs go down the outgoing connection? I've tried to convert this but I don't know what in the hell I'm doing...
________________________________________________________________________
// thanks to xbytor for regexp;
// 2012, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var myDoc = app.activeDocument;
var docName = myDoc.name;
try {var basename = docName.match(/(.*).[^.]+$/)[1];
var docPath = myDoc.path}
catch (e) {var basename = docName;
var docPath = "~/Desktop"};
// try to get set »Main colors« in »product«;
try {
var theSet = myDoc.layers.getByName("group").layers.getByName("colors");
for (var n = 0; n < theSet.layers.length; n++) {
theSet.layers[n].visible = false;
};
// process;
for (var m = 0; m < theSet.layers.length; m++) {
var thisLayer = theSet.layers[m];
thisLayer.visible = true;
var layerName = thisLayer.name;
while (layerName.indexOf("/") != -1) {layerName = layerName.replace("/", "_")};
saveFlattenedTiff (myDoc, basename + "_" + layerName, docPath)
thisLayer.visible = false;
}
}
catch (e) {alert ("can’t locate folder")};
};
////// function to save the flattened tiff from copy //////
function saveFlattenedTiff (myDoc, basename, docPath) {
tifOpts = new TiffSaveOptions();
tifOpts.embedColorProfile = true;
tifOpts.imageCompression = TIFFEncoding.TIFFLZW;
tifOpts.alphaChannels = false;
tifOpts.byteOrder = ByteOrder.MACOS;
tifOpts.layers = false;
myDoc.saveAs((new File(docPath+"/"+basename+".tif")),tifOpts,true)
};
________________________________________________________________________
Any help would be greatly appreciated.
Thanks
JG
I have a script that works great when ran manually. I want to use it in a switch flow. This script creates Tifs from adjustment layers in the open document. Is it possible to have all of these new tifs go down the outgoing connection? I've tried to convert this but I don't know what in the hell I'm doing...
________________________________________________________________________
// thanks to xbytor for regexp;
// 2012, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var myDoc = app.activeDocument;
var docName = myDoc.name;
try {var basename = docName.match(/(.*).[^.]+$/)[1];
var docPath = myDoc.path}
catch (e) {var basename = docName;
var docPath = "~/Desktop"};
// try to get set »Main colors« in »product«;
try {
var theSet = myDoc.layers.getByName("group").layers.getByName("colors");
for (var n = 0; n < theSet.layers.length; n++) {
theSet.layers[n].visible = false;
};
// process;
for (var m = 0; m < theSet.layers.length; m++) {
var thisLayer = theSet.layers[m];
thisLayer.visible = true;
var layerName = thisLayer.name;
while (layerName.indexOf("/") != -1) {layerName = layerName.replace("/", "_")};
saveFlattenedTiff (myDoc, basename + "_" + layerName, docPath)
thisLayer.visible = false;
}
}
catch (e) {alert ("can’t locate folder")};
};
////// function to save the flattened tiff from copy //////
function saveFlattenedTiff (myDoc, basename, docPath) {
tifOpts = new TiffSaveOptions();
tifOpts.embedColorProfile = true;
tifOpts.imageCompression = TIFFEncoding.TIFFLZW;
tifOpts.alphaChannels = false;
tifOpts.byteOrder = ByteOrder.MACOS;
tifOpts.layers = false;
myDoc.saveAs((new File(docPath+"/"+basename+".tif")),tifOpts,true)
};
________________________________________________________________________
Any help would be greatly appreciated.
Thanks
JG