Mobile app version of vmapp.org
Login or Join
Samaraweera207

: How to use jsx script in adobe Photoshop I found this piece of script offer by a solution on exactly what I try to do here. But I have no idea and can find no related info about this

@Samaraweera207

Posted in: #AdobePhotoshop #Cs6 #PhotoshopScripting

I found this piece of script offer by a solution on exactly what I try to do here. But I have no idea and can find no related info about this jsx script. I wonder where should I put it or use it in Adobe Photoshop CS6? I tried to use the script with Script->browse and double click on the file named script.jsx where I pasted the code below for export each layer into a file that has SAME background layer applied instead of the default transparent background. However, after I used it, nothing really happened and no error pop up. So I am not sure if anything I have done is not correct.

// variables
var destination = "C:/Users/...../"
var doc = app.activeDocument;
var artlayers = new Array();

// jpeg options
var options = new ExportOptionsSaveForWeb();
options.quality = 80;
options.format = SaveDocumentType.JPEG;

// loop through all layers
var x = 0;
var a = 0;
while (x < doc.layers.length) {
// check if the layer is a item
if (doc.layers[x].kind == LayerKind.NORMAL) {
// add to array
artlayers[a] = x;
a++;
}
x++;
}

var x = 0;
var a = 0;

for (x=0; x < artlayers.length; x++)

{
doc.layers[artlayers[x]].visible = true;
// export as jpeg
try { doc.backgroundLayer.visible = true; } catch (e) {}
file = new File(destination + doc.layers[artlayers[x]].name +".jpg");
doc.exportDocument(file, ExportType.SAVEFORWEB, options);
doc.layers[artlayers[x]].visible = false;
}


Thanks!

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Samaraweera207

1 Comments

Sorted by latest first Latest Oldest Best

 

@Samaraweera207

The script does work if you mess around with it a bit. And yes, joojaa is correct, it is a JSX.

Line 2 needs to be changed to an actual destination using slashes instead of backslashes, plus a semicolon at the end. I.e.,

var destination = "C:/Users/USERNAME/FOLDER/";


You could also alter line 9 to

options.quality = 100;


if you aren't actually saving for web and want to retain as much of the file's original quality as you can since this script is turning your PSD into a bunch of JPGs instead of PNGs.

I think you'll have to use the Browse function to utilize the script. PS doesn't seem to recognize its existence if you put it into PresetsScripts.

That's as far as I can take it. I'm not a coder.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme