ExportOptionsSaveForWeb - GRAYSCALE

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Kukurykus, Tom, xbytor

KasAndr
Posts: 1
Joined: Tue Jun 23, 2020 1:31 pm

ExportOptionsSaveForWeb - GRAYSCALE

Post by KasAndr »

Hi friends, there is a coolass script for saving masks, it is very necessary to get a picture in grayscale at the output, for some reason I can’t do it :(

Code: Select all

app.preferences.rulerUnits=Units.PIXELS;
app.preferences.typeUnits=TypeUnits.PIXELS;
var d = app.activeDocument;
var savedState = d.activeHistoryState;
d.resizeImage(2048,2048);

var pth=d.path.toString();
pth=pth.slice(0,pth.lastIndexOf("/")+1);
var fname=pth+"../textures_masks_gs/" +d.activeLayer.name+".png";

var fl=new File(fname);
fl=fl.saveDlg("Select path:");
var expOptions=new ExportOptionsSaveForWeb;
expOptions.format=SaveDocumentType.PNG;
expOptions.PNG8=true;
expOptions.includeProfile=true;
expOptions.ColorReductionType=ColorReductionType.GRAYSCALE;
expOptions.dither=Dither.NONE;
expOptions.webSnap=0;
expOptions.colors=128;
expOptions.transparency=0;
d.changeMode(ChangeMode.GRAYSCALE);
d.exportDocument(fl,ExportType.SAVEFORWEB,expOptions);
d.activeHistoryState = savedState;