Getting Channel Information


ok, i'm trying write script copies spot color channels directly layers.  know how copy information over, , figured out how name transfer, i'm hung right trying color overlay new layer spot color of old channel.

 

 

 

how grab spot color variable can later call out in color overlay?

if understand asking, want way know color used when spot channel created. threw existing funcitons have. seems work not tested there may color modes fails.

 

var spotcolor = getspotchannelcolor(); // spotcolor undefined if channel not spot channel // if channel spot channel spotcolor either solidcolor object // or custom bookcolor object depending in color used create spot channel // not tested. function getspotchannelcolor(index){     var desc = getproperty(charidtotypeid("chnl"),charidtotypeid("achn"), index);      if(desc != undefined){         var channeltype = desc.getenumerationvalue(charidtotypeid("clri"));         if(channeltype == charidtotypeid('spot')){             var colordesc = desc.getobjectvalue( charidtotypeid("clr "));             return getcolorfromdescriptor( colordesc, typeidtocharid(desc.getclass(charidtotypeid("clr "))));         }     }     return undefined; }; function getcolorfromdescriptor( colordesc, keyclass ){     var colorobject = new solidcolor();     switch( keyclass ){         case "grsc":             colorobject.grey.grey = color.getdouble(charidtotypeid('gry '));             break;         case "rgbc":             colorobject.rgb.red = colordesc.getdouble(charidtotypeid('rd  '));             colorobject.rgb.green = colordesc.getdouble(charidtotypeid('grn '));             colorobject.rgb.blue = colordesc.getdouble(charidtotypeid('bl  '));             break;         case "cmyc":             colorobject.cmyk.cyan = colordesc.getdouble(charidtotypeid('cyn '));             colorobject.cmyk.magenta = colordesc.getdouble(charidtotypeid('mgnt'));             colorobject.cmyk.yellow = colordesc.getdouble(charidtotypeid('ylw '));             colorobject.cmyk.black = colordesc.getdouble(charidtotypeid('blck'));             break;         case "lbcl":             colorobject.lab.l = colordesc.getdouble(charidtotypeid('lmnc'));             colorobject.lab.a = colordesc.getdouble(charidtotypeid('a   '));             colorobject.lab.b = colordesc.getdouble(charidtotypeid('b   '));         case "hsbc":             colorobject.hsb.hue = colordesc.getdouble(charidtotypeid('h   '));             colorobject.hsb.saturation = colordesc.getdouble(charidtotypeid('strt'));             colorobject.hsb.brightness = colordesc.getdouble(charidtotypeid('brgh'));             break;         case "bkcl":               colorobject = {};             colorobject.book = colordesc.getstring(charidtotypeid('bk  '));             colorobject.name = colordesc.getstring(charidtotypeid('nm  '));             colorobject.bookid = colordesc.getinteger(stringidtotypeid('bookid'));               colorobject.bookkey = colordesc.getdata(stringidtotypeid('bookkey'));               colorobject.typename = "bookcolor";               colorobject.tostring = function(){return this.book+' - '+this.name;}             break;         default: return null;     }     return colorobject; };  function getproperty( psclass, pskey, index ){// integer:class, integer:key     var ref = new actionreference();     if( pskey != undefined ) ref.putproperty( charidtotypeid( "prpr" ), pskey );     if(index != undefined ){         ref.putindex( psclass, index );     }else{         ref.putenumerated( psclass , charidtotypeid( "ordn" ), charidtotypeid( "trgt" ) );     }     try{         var desc = executeactionget(ref);     }catch(e){ return; }// return on error     if(desc.count == 0) return;// return undefined if property doesn't exists     var datatype = desc.gettype(pskey);     switch(datatype){// not types supported - returns undefined if not supported         case descvaluetype.integertype:             return desc.getinteger(pskey);             break;         case descvaluetype.aliastype:             return desc.getpath(pskey);             break;         case descvaluetype.booleantype:             return desc.getboolean(pskey);             break;         case descvaluetype.booleantype:             return desc.getboolean(pskey);             break;         case descvaluetype.unitdouble:             return desc.getunitdoublevalue(pskey);             break;         case descvaluetype.stringtype:             return desc.getstring(pskey);             break;         case  descvaluetype.objecttype:             return desc.getobjectvalue(pskey);             break;         case  descvaluetype.enumeratedtype:             return desc.getenumerationvalue(pskey);             break;     } }; 


More discussions in Photoshop Scripting


adobe

Comments

Popular posts from this blog

how to devide a circle into equal parts

"Could not fill because there are not enough opaque source pixels" - not solved by any other thread

Why can't I change the billing info for my account?