How To - Photoshop Script - Merge Two Layers
My Photoshop Canvas is 900X600.
The function below takes Layer X and makes Layer X copy.
It takes Layer X copy and while maintaining the ratio adjusts the height to 600px. var newdLayer
It takes Layer X and while maintaining the ratio adjusts the width to 900px and applies the Gaussian Blur. var blur.
I want to then merge Layer X copy and Layer X.
Apparently there is a merge() function, but for that you have to crate a layerset. Not really a pro at javascript.
How to merge the two layers?
(function (){
var docRef = activeDocument
var newdLayer = docRef.activeLayer.duplicate();
newdLayer;
var startRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var bounds = newdLayer.bounds;
var height = bounds[3].value - bounds[1].value;
var newSize = (100 / height) * 600;
newdLayer.resize(newSize, newSize, AnchorPosition.MIDDLECENTER);
app.preferences.rulerUnits = startRulerUnits;
var blur = docRef.activeLayer;
var startRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var bounds = blur.bounds;
var width = bounds[2].value - bounds[0].value;
var newSize = (100 / width) * 900;
blur.resize(newSize, newSize, AnchorPosition.MIDDLECENTER);
app.preferences.rulerUnits = startRulerUnits;
blur.applyGaussianBlur(5)
blur;
})();
