Per-layer metadata


i've searching around web quite lot regarding haven't been able find kind of official information it:

does functionality exists in ps cc, , if so: can find code examples?

here script written paul riggott, "per layer guides"

 

#target photoshop //written paul riggott main(); function main(){ if(number(app.version.match(/\d+/)) <12) return; if(!documents.length) return; var doc =activedocument; if(doc.activelayer.isbackgroundlayer) return; if(doc.activelayer.kind != layerkind.normal) return; if (externalobject.adobexmpscript == undefined)  externalobject.adobexmpscript = new externalobject("lib:adobexmpscript"); var startrulerunits = app.preferences.rulerunits; app.preferences.rulerunits = units.pixels; if(scriptui.environment.keyboardstate.shiftkey ){     setguides();     }else{         displayguides();         } app.preferences.rulerunits = startrulerunits;  function setguides(){ try{     xmp = doc.activelayer.xmpmetadata.rawdata;     xmpobject = new xmpmeta(xmp); } catch(e){     xmpobject = new xmpmeta(); } var psnamespace = "http://ns.layerguides/1.0/"; var psprefix = "pmrguides:"; xmpmeta.registernamespace(psnamespace, psprefix); var guides = app.activedocument.guides; if(guides.length == 0){     alert("no guides exist");     return;     } var gh = ''; var gv = ''; for( var g = 0; g < guides.length; g++ ){     if(guides[g].direction.tostring() == 'direction.horizontal'){         gh+=(parseint(guides[g].coordinate.value));         gh+=',';         }else{             gv+=(parseint(guides[g].coordinate.value));             gv+=','             } } gh=gh.replace(/,$/,''); gv=gv.replace(/,$/,''); currentguides = 'layer guides' + "¬" + gh + "¬" + gv; xmpobject.deleteproperty(psnamespace, "layerguides"); xmpobject.setproperty(psnamespace, "layerguides",currentguides); app.activedocument.activelayer.xmpmetadata.rawdata = xmpobject.serialize(); } function displayguides(){ try{     xmp = doc.activelayer.xmpmetadata.rawdata;     xmpobject = new xmpmeta(xmp); } catch(e){     return; } var psnamespace = "http://ns.layerguides/1.0/"; var psprefix = "pmrguides:"; var layerguides = xmpobject.getproperty(psnamespace, "layerguides"); clearguides(); var ar1 = layerguides.tostring().split('¬'); var hor = ar1[1].tostring().split(','); var ver = ar1[2].tostring().split(','); for(var h in hor){     activedocument.guides.add(direction.horizontal,new unitvalue(number(hor[h]),'px'));     } for(var v in ver){     activedocument.guides.add(direction.vertical,new unitvalue(number(ver[v]),'px'));     } } } function clearguides() {     var id556 = charidtotypeid( "dlt " );         var desc102 = new actiondescriptor();         var id557 = charidtotypeid( "null" );             var ref70 = new actionreference();             var id558 = charidtotypeid( "gd  " );             var id559 = charidtotypeid( "ordn" );             var id560 = charidtotypeid( "al  " );             ref70.putenumerated( id558, id559, id560 );         desc102.putreference( id557, ref70 );     executeaction( id556, desc102, dialogmodes.no );  };  


More discussions in Photoshop Scripting


adobe

Comments

Popular posts from this blog

Soustraire une selection

After Effects: could not find dvaeve_dialogs.txt

Illustrator cs6 "Invalid Serial Number"