How to change photoshop layer icon color using Adobe ExtendScript?
Color Codes :
1 2 3 4 5 6 7 8 |
None // No Color 'Rd ' // Red 'Orng' // Orange 'Ylw ' // Yellow 'Grn ' // Green 'Bl ' // Blue 'Vlt ' // Violet 'Gry ' // Gray |
Code Snippet ( changes current active layer icon’s color)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
// Script Snippet // Change active layer icon's color // Usage : Change_Layer_Icon_Color(1,0,'red'); #target photoshop cTID = function(s) { return app.charIDToTypeID(s); }; sTID = function(s) { return app.stringIDToTypeID(s); }; function Change_Layer_Icon_Color(enabled, withDialog,color) { var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); var desc1 = new ActionDescriptor(); var ref1 = new ActionReference(); ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt')); desc1.putReference(cTID('null'), ref1); var desc2 = new ActionDescriptor(); colorcode = 'None'; if (color =='none' || color == 'None' || color == 'no' || color == '' ) { colorcode = 'None'; } if (color =='Red' || color == 'red') { colorcode = 'Rd '; } if (color =='Orange' || color == 'orange') { colorcode= 'Orng'; } if (color =='Yellow' || color == 'yellow') { colorcode ='Ylw '; } if (color =='Green' || color == 'green') { colorcode ='Grn '; } if (color =='Blue' || color == 'blue') { colorcode ='Bl '; } if (color =='Violet' || color == 'violet' || color == 'purple' || color == 'Purple') { colorcode ='Vlt '; } if (color =='Gray' || color == 'gray' || color == 'Grey' || color == 'grey' ) { colorcode ='Gry '; } desc2.putEnumerated(cTID('Clr '), cTID('Clr '), cTID(colorcode)); desc1.putObject(cTID('T '), cTID('Lyr '), desc2); executeAction(cTID('setd'), desc1, dialogMode); }; Change_Layer_Icon_Color(1,0,'violet'); |
Now you can change active layer icon’s color to red,orange,yellow and etc…
Replace;
1 |
Change_Layer_Icon_Color(1,0,'violet'); |
to;
1 |
Change_Layer_Icon_Color(1,0,'red'); |
Leave a Reply
Want to join the discussion?Feel free to contribute!