Skip to main content
_scott__
Legend
November 28, 2011
Open for Voting

Photoshop: Remove unused layer styles

  • November 28, 2011
  • 26 replies
  • 3690 views
Feature Request....

Option to remove unused Layer Styles.
Control-click/Right-click the fx icon for a Layer and get...

| Copy Layer Style |
| Paste Layer Style |
| Clear Unused Styles | (NEW)
| Clear Layer Styles |



I spend so much time manually click-dragging empty layer style options to the trash.

Thanks!

26 replies

_scott__
_scott__Author
Legend
May 3, 2012
Hi Zorana,

Interesting but the "clear layer styles" command removed all style attributes. What I would like to see is to remove non-visible or hidden attributes.

If I have a layer....


When I copy layers the hidden Effects copy with the layer. While working I may copy a layer many times.

If I attempt to use the new layer search to target layers with the Stroke effect......


The layers don't show because the effect is hidden.

I actually agree with Simon, I'd prefer a global command to remove all hidden layer styles so in one fell swoop I can eliminate all those non-visible style attributes on all layers. The command would be more similar to the Delete Hidden Layers command, but only remove style attributes.

I'd alos like it if when option-dragging to copy Layer Styles between layers, if ONLY the visible style attributes copied, not all attributes.
Participant
May 3, 2012
In Photoshop CS6 we added Layer Search. Within that you can also search for layers by Attribute (i.e. Find all layers with Attribute Layer Effects or that are invisible). From there you can select the layers and delete them or whatever. One option is to add the ability to search by Attribute: Unused Layer Styles. Then you could select the layers and "Clear Layer Styles". How does that idea resonate?
Participant
May 3, 2012
Cool! I will defo give it a try!
_scott__
_scott__Author
Legend
May 3, 2012
Thanks Paul. I'll absolutely try it.
Paul Riggott
Inspiring
May 3, 2012
In the mean time you could try this script...



#target photoshop
app.bringToFront();

app.activeDocument.suspendHistory('Remove Unused FX', 'main()');

function main(){
if(!documents.length) return;
selectAllLayers();
var selLayers = getSelectedLayersIdx();
for(var a in selLayers){
clearUnusedFX(Number(selLayers[a]));
}
}
function clearUnusedFX(idx){
var ref = new ActionReference();
ref.putProperty( charIDToTypeID("Prpr") , stringIDToTypeID( "layerEffects" ));
ref.putIndex( charIDToTypeID( "Lyr " ), idx);
var desc = executeActionGet(ref);
if(desc.hasKey(stringIDToTypeID('layerEffects'))){
makeActiveByIndex( idx );
var FXs = desc.getObjectValue(stringIDToTypeID('layerEffects'));
var ref9 = new ActionReference();
ref9.putProperty( charIDToTypeID("Prpr") , stringIDToTypeID( 'layerFXVisible'));
ref9.putIndex( charIDToTypeID( "Lyr " ), idx);
var vis = executeActionGet(ref9);
var delALL = undefined;
if(vis.hasKey(stringIDToTypeID('layerFXVisible'))) delALL = vis.getBoolean(stringIDToTypeID('layerFXVisible'));
}else{
return;
}
var c = FXs.count;
var Effects= new Array();
for(var i=0;i<c;i++){
Effects.push(typeIDToStringID(FXs.getKey(i)));
}
for(var z in Effects){
if(z == 0) continue;
var bool = FXs.getObjectValue(stringIDToTypeID(Effects[z].toString())).getBoolean (stringIDToTypeID('enabled'));
if(!bool || delALL == false) delFx(Effects[z].toString());
}
function delFx(fx){
var desc147 = new ActionDescriptor();
var ref45 = new ActionReference();
switch(fx.toString()){
case 'dropShadow' : ref45.putClass(charIDToTypeID('DrSh')); break;
case 'innerShadow' : ref45.putClass(charIDToTypeID('IrSh')); break;
case 'outerGlow' : ref45.putClass(charIDToTypeID('OrGl')); break;
case 'innerGlow' : ref45.putClass(charIDToTypeID('IrGl')); break;
case 'bevelEmboss' :ref45.putClass(charIDToTypeID('ebbl')); break;
case 'frameFX' : ref45.putClass(charIDToTypeID('FrFX')); break;
case 'chromeFX' : ref45.putClass(charIDToTypeID('ChFX')); break;
case 'solidFill' : ref45.putClass(charIDToTypeID('SoFi')); break;
case 'gradientFill' : ref45.putClass(charIDToTypeID('GrFl')); break;
case 'patternFill' : ref45.putClass(stringIDToTypeID('patternFill')); break;
default : break;
}
ref45.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc147.putReference( charIDToTypeID('null'), ref45 );
try{
executeAction( charIDToTypeID('dsfx'), desc147, DialogModes.NO );
}catch(e){}
}
}
function makeActiveByIndex( idx ){
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putIndex(charIDToTypeID( "Lyr " ), idx)
desc.putReference( charIDToTypeID( "null" ), ref );
desc.putBoolean( charIDToTypeID( "MkVs" ), true );
executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
};
function selectAllLayers() {
var desc29 = new ActionDescriptor();
var ref23 = new ActionReference();
ref23.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc29.putReference( charIDToTypeID('null'), ref23 );
executeAction( stringIDToTypeID('selectAllLayers'), desc29, DialogModes.NO );
}
function getSelectedLayersIdx(){
var selectedLayers = new Array;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);
if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
var c = desc.count
var selectedLayers = new Array();
for(var i=0;i<c;i++){
try{
activeDocument.backgroundLayer;
selectedLayers.push( desc.getReference( i ).getIndex() );
}catch(e){
selectedLayers.push( desc.getReference( i ).getIndex()+1 );
}
}
}else{
var ref = new ActionReference();
ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
try{
activeDocument.backgroundLayer;
selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1);
}catch(e){
selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" )));
}
}
return selectedLayers;
};
Participant
May 3, 2012
This is exacetly what drives me crazy too!

My suggestion would be to have a button which says: "Consolidate all unused layer styles" which then would remove them. Rather than doing this by hand to many single layers, I think it would be a nice to have on a global scale.