-1

I've got this script from an earlier question and answer (specific resize layer action) Many thanks to SQW!

(function (){
    var startRulerUnits = app.preferences.rulerUnits;  
    app.preferences.rulerUnits = Units.PIXELS;
    var bounds = activeDocument.activeLayer.bounds;  
    var width = bounds[2].value - bounds[0].value;
    var newSize = (100 / width) * 550; 
    activeDocument.activeLayer.resize(newSize, newSize, AnchorPosition.BOTTOMLEFT);
    app.preferences.rulerUnits = startRulerUnits;  
})();

However, is it possible for the script to only run when the layer that needs to be resized is, for example, greater than 550px? I am a complete noob when it comes to scripting, and I've tried adding in an "if" function but I just don't understand how it works...

Many thanks.

  • 2
    I'm voting to close this question as off-topic because it isn't graphic design related. – Hanna Apr 15 '16 at 21:28
0

Thanks to SuperMerlin over at the adobe forums, he has given me the answer.

(function (){ 
    var startRulerUnits = app.preferences.rulerUnits;   
    app.preferences.rulerUnits = Units.PIXELS; 
    var bounds = activeDocument.activeLayer.bounds;   
    var width = bounds[2].value - bounds[0].value; 
    if(width > 550){
        var newSize = (100 / width) * 550;   
        activeDocument.activeLayer.resize(newSize, newSize, AnchorPosition.BOTTOMLEFT); 
    }
    app.preferences.rulerUnits = startRulerUnits;
})(); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.