pfaffenbichler wrote:You can try this:
Code: Select all#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
// if only one horizontal guide exists resize;
if (myDocument.guides.length == 1) {
if (myDocument.guides[0].direction == "Direction.HORIZONTAL") {
var originalUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var theValue = myDocument.guides[0].coordinate;
var theHeight = (myDocument.height - theValue) * 2;
myDocument.resizeCanvas(myDocument.width, theHeight, AnchorPosition.BOTTOMCENTER);
// ad corner pixels;
myDocument.selection.deselect();
var thisColor = new SolidColor;
thisColor.rgb.red = 0;
thisColor.rgb.green = 0;
thisColor.rgb.blue = 0;
var theW = myDocument.width;
var theH = myDocument.height;
addPixel([[0,0], [0,1], [1,1], [1,0]]);
addPixel([[theW,0], [theW,1], [theW-1,1], [theW-1,0]]);
addPixel([[theW,theH], [theW-1,theH], [theW-1,theH-1], [theW,theH-1]]);
addPixel([[0,theH], [0,theH-1], [1,theH-1], [1,theH]]);
myDocument.selection.fill(thisColor);
myDocument.selection.deselect();
// reset;
app.preferences.rulerUnits = originalUnits;
}
}
};
function addPixel (theArray) {
app.activeDocument.selection.select(theArray, SelectionType.EXTEND, 0, false);
};
Many thanks pfaffenbichler! works just how i would like it to!