: Add a conditional line to existing script I've got this script from an earlier question and answer (specific resize layer action) Many thanks to SQW! (function (){ var startRulerUnits =
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.
More posts by @Miguel516
1 Comments
Sorted by latest first Latest Oldest Best
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;
})();
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.