stop panel from expanding...


i wrote script samples 4 points the upper lefthand corner of image, , uses rgb values color select entire background. purpose of later in action (but not in script) selection can inverted , made new layer.

 

taken whole process removes background of image. but, works if colors in upper left corner representative of entire background , background uniform.

 

i posting 3 reasons:

 

1) in case finds or snippets of useful

 

2) in case has suggestions ways script improved...specifically feel arrays have been assembled more concise fashion....?

 

3) because every time play script causing (usually closed) info panel open creates color samples , it's driving me crazy. there type of .dialogsno option can put somewhere in here keep happening? or if not there can add end of script close it?

 

#target photoshop  var doc = app.activedocument  doc.colorsamplers.removeall();   var samp1 = doc.colorsamplers.add([1,1]);  var samp1r = samp1.color.rgb.red;  var samp1g = samp1.color.rgb.green;  var samp1b = samp1.color.rgb.blue;  var samp2 = doc.colorsamplers.add([15,1]);  var samp2r = samp2.color.rgb.red;  var samp2g = samp2.color.rgb.green;  var samp2b = samp2.color.rgb.blue;  var samp3 = doc.colorsamplers.add([1,15]);  var samp3r = samp3.color.rgb.red;  var samp3g = samp3.color.rgb.green;  var samp3b = samp3.color.rgb.blue;  var samp4 = doc.colorsamplers.add([15,15]);  var samp4r = samp4.color.rgb.red;  var samp4g = samp4.color.rgb.green;  var samp4b = samp4.color.rgb.blue;  var reds = new array; var greens = new array; var blues = new array;  reds.push([samp1r],[samp2r],[samp3r],[samp4r]); greens.push([samp1g],[samp2g],[samp3b],[samp4g]); blues.push([samp1b],[samp2b],[samp3b],[samp4b]);  redsmax = math.max.apply(math, reds); greensmax = math.max.apply(math, greens); bluesmax = math.max.apply(math, blues);  redsmin = math.min.apply(math, reds); greensmin = math.min.apply(math, greens); bluesmin = math.min.apply(math, blues);  //-----------key adustments----------// tolerance = 25; fuziness = 40; //-----------key adustments----------//  redsmaxadjusted = redsmax - (tolerance/5); greensmaxadjusted = greensmax- (tolerance/5); bluesmaxadjusted = bluesmax- (tolerance/5);  redsminadjusted = redsmin - tolerance; greensminadjusted = greensmin - tolerance; bluesminadjusted = bluesmin- tolerance;  app.activedocument.suspendhistory ("autoselect", "selectcolorrange( redsminadjusted, greensminadjusted, bluesminadjusted, redsmaxadjusted, greensmaxadjusted, bluesmaxadjusted, fuziness )");  function selectcolorrange (minr, ming, minb, maxr, maxg, maxb, fuzz) { var idclrr = charidtotypeid( "clrr" );     var desc4 = new actiondescriptor();     var idfzns = charidtotypeid( "fzns" );     desc4.putinteger( idfzns, fuzz );     var idmnm = charidtotypeid( "mnm " );         var desc5 = new actiondescriptor();         var idr = charidtotypeid( "rd  " );         desc5.putdouble( idr, minr );         var idg = charidtotypeid( "grn " );         desc5.putdouble( idg, ming );         var idb = charidtotypeid( "bl  " );         desc5.putdouble( idb, minb );     var idrgcl = charidtotypeid( "rgbc" );     desc4.putobject( idmnm, idrgcl, desc5 );     var idmxm = charidtotypeid( "mxm " );         var desc6 = new actiondescriptor();         var idr = charidtotypeid( "rd  " );         desc6.putdouble( idr, maxr );         var idg = charidtotypeid( "grn " );         desc6.putdouble( idg, maxg );         var idb = charidtotypeid( "bl  " );         desc6.putdouble( idb, maxb );     var idrgcl = charidtotypeid( "rgbc" );     desc4.putobject( idmxm, idrgcl, desc6 );     var idcolormodel = stringidtotypeid( "colormodel" );     desc4.putinteger( idcolormodel, 0 ); executeaction( idclrr, desc4, dialogmodes.no ); }; 

you add...

app.runmenuitem (stringidtotypeid ("closeinfopanel"));

this should close info panel.



More discussions in Photoshop Scripting


adobe

Comments

Popular posts from this blog

Illustrator CS6 Ocurrío un error E/S en el archivo.

Why is os_ViewContainer running?

Animate - problem with duplicating scripts after loop