#target photoshop
function main(){
var Dlg =
"dialog{text:'Script Interface',bounds:[100,100,500,290],"+
"Text:StaticText{bounds:[20,20,240,40] , text:'Emulate B&W Film' ,properties:{scrolling:undefined,multiline:undefined}},"+
"panel0:Panel{bounds:[10,10,390,180] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true}"+
"Film:DropDownList{bounds:[20,70,270,90]},"+
"button0:Button{bounds:[20,110,120,130] , text:'Ok' },"+
"button1:Button{bounds:[250,110,350,130] , text:'Cancel' }}};"
win2 = new Window(Dlg,"Convert Colour to B&W");
var bwList = [['Agfa 200X',18,41,41],
['Agfapan 25',25,39,36],
['Agfapan 100',21,40,39],
['Agfapan 400',20,41,39],
['Ilford Delta 100',21,42,37],
['Ilford Delta 400',22,42,36],
['Ilford Delta 400 Pro',31,36,33],
['Ilford FP4',28,41,31],
['Ilford HP5',23,37,40],
['Ilford Pan F',33,36,31],
['Ilford SFX',36,31,33],
['Ilford XP2 Super',21,42,37],
['Kodak Tmax 100',24,37,39],
['Kodak Tmax 400',27,36,37],
['Kodak Tri-X',25,35,40]];
for (i in bwList) {
win2.panel0.Film.add('item',bwList[i][0])
}
win2.panel0.Film.selection=0;
win2.panel0.Film.onChange = function(){
Sel = parseInt(this.selection);
}
var done = false;
while (!done) {
var x = win2.show();
if (x == 0 || x == 2) {
win2.canceled = true;
done = true;
} else if (x == 1) {
done = true;
var result = valiDate();
if(result != true) {
alert(result);
return;
}else
{
if(documents.length){
BlackWhite(bwList[Sel][1],bwList[Sel][2],bwList[Sel][3]);
}
}
}
}
}
main();
function valiDate(){
return true;
};
function BlackWhite(Red,Green,Blue) {
function cTID(s) { return app.charIDToTypeID(s); };
function sTID(s) { return app.stringIDToTypeID(s); };
var desc2 = new ActionDescriptor();
desc2.putEnumerated( sTID('presetKind'), sTID('presetKindType'), sTID('presetKindCustom') );
desc2.putBoolean( cTID('Mnch'), true );
var desc3 = new ActionDescriptor();
desc3.putUnitDouble( cTID('Rd '), cTID('#Prc'), Red );
desc3.putUnitDouble( cTID('Grn '), cTID('#Prc'), Green );
desc3.putUnitDouble( cTID('Bl '), cTID('#Prc'), Blue );
desc2.putObject( cTID('Gry '), cTID('ChMx'), desc3 );
executeAction( cTID('ChnM'), desc2, DialogModes.NO );
};