Help get this topic noticed by sharing it on Twitter, Facebook, or email.
I’m sure it's a good idea

Photoshop: Remove unused layer styles

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!
14 people like
this idea
+1
Reply
  • 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.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • 1
    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;
    };
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • Zorana Gee (Photoshop Product Manager) May 03, 2012 23:03
    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?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • 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.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • I have just tried the script Paul has posted earlier. That works well and is all I need.
    The only thing which would top it would be an integrated function/button in the layer menu (right click on a layer) similar to what Scott has suggested.

    I guess I will build a panel using the Configurator now and integrate the script myself.

    Edit: I have built a Configurator panel now which links to the .jsx script in my "../Presets/Scripts" folder (works fine). Can anyone tell me how I could use the script from Paul in Configurator without linking to an external file. Whenever I copy this source code into a script "button" nothing happens... Thanks a ton!

    Edit II: After a bit of testing I come to following result: The script works perfect, with one little "imperfection". As far as I understand, it goes through all the layers (no matter whether the layers are hidden or not) checks all the different layer styles and if some of them are unticked, it removes them. But what it also does is it switches hidden layers on to check them and leaves them visible. Which is a problem if you work with layer comps - some of my layers are hidden for a reason and if the script suddenly switches them back on it creates a situation which takes lots of time to fix again. @ Paul - can the script be modified so that this can be avoided (leave the layer visibilty as it was before?)
    I would do it myself but I don't understand how to script :(
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • Hi Simon, sorry about that, change the line in the makeActiveByIndex( idx ) function...

    From :-
    desc.putBoolean( charIDToTypeID( "MkVs" ), true );

    To :-
    desc.putBoolean( charIDToTypeID( "MkVs" ), false );

    That should fix the problem.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • Paul,

    This is excellent. Exactly what I needed. Thank you!
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • I hope you have made the above change Scott and glad it works for you.

    Simon if you do a lot with Layercomps I have another script that removes layers that are not used in any layercomp, it just cleans the psd. It's here if it's any use to you...
    http://www.scriptsrus.talktalk.net/Cl...
    Maybe you could add it to your configurator panel.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • Yes. I made the change before trying it. Works wonderfully, Paul. Thanks again.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • Hi to all of you :)

    just coming back from a weekend away - so I haven't been able to test the latest changes on the script. Will do it tomorrow.

    Paul I am sure it'll work - thanks a lot for your help there!! I will also have a look the 2nd script you've mentioned.

    Edit: Btw if someone's keen to install the panel mentioned above, give me a shout.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • My suggestion would be to have a global ‘Clear Layer Styles’ option beneath the existing ’Delete Hidden Layers’ entry in the Layers palette fly out menu.

    In fact there's a whole host of clean up options that would be very useful: Delete Empty Groups, Delete Empty Layer Masks, Delete Empty Vector Masks, Delete Empty Layers, Delete hidden maks, etc.

    On top of this an overall ‘Clean up file’ option could execute all of these commands, reducing a file to its current viewing state.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • 2
    This reply was created from a merged topic originally titled
    Photoshop: Ability to delete all hidden layer effects.


    After working on a document I end up with hundreds of hidden layer effects that were experiments. Just like there's an option to delete all hidden layers, there should be an option to delete all hidden layer effects.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned