Hey wondering if you guys can help me out? i have no idea how to start this or if this is possible
Steps are below which im after to prepare a document:
steps:
1.
Starting document, if we can make the guide in the middle of the document. By getting the height of the guide from the bottom of the document. Then extending the canvas up that amount. so the guide will become in the centre of the document in the height.
2.
This is what we end up with from the first step
Adding one pixel at each corner of the document. Has to be one black pixel at each corner of the document.
These are the bottom corners.
Top corners adding one pixel in each corner
3.
Thats its, document extended height from the guide height, then adding one black pixel at each corner.
Thanks this will really help me out if this can be done!
preparation of document HELP
-
pfaffenbichler
preparation of document HELP
This should address one point.
Code: Select all// 2014, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
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);
app.preferences.rulerUnits = originalUnits;
}
}
};
As for the corner pixels check out
Selection.select (region:Array of any, type: SelectionType , feather: number , antiAlias: Boolean )
You can run that four times with an Array of the coordinates of the corners of each corner-pixel and SelectionType.Extend, then fill.
Code: Select all// 2014, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
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);
app.preferences.rulerUnits = originalUnits;
}
}
};
As for the corner pixels check out
Selection.select (region:Array of any, type: SelectionType , feather: number , antiAlias: Boolean )
You can run that four times with an Array of the coordinates of the corners of each corner-pixel and SelectionType.Extend, then fill.
-
boogotti
preparation of document HELP
pfaffenbichler wrote:This should address one point.
Code: Select all// 2014, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
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);
app.preferences.rulerUnits = originalUnits;
}
}
};
As for the corner pixels check out
Selection.select (region:Array of any, type: SelectionType , feather: number , antiAlias: Boolean )
You can run that four times with an Array of the coordinates of the corners of each corner-pixel and SelectionType.Extend, then fill.
Thank you pfaffenbichler i give it a try, im abit lost what you mean by the As for the corner pixels code?
Code: Select all// 2014, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
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);
app.preferences.rulerUnits = originalUnits;
}
}
};
As for the corner pixels check out
Selection.select (region:Array of any, type: SelectionType , feather: number , antiAlias: Boolean )
You can run that four times with an Array of the coordinates of the corners of each corner-pixel and SelectionType.Extend, then fill.
Thank you pfaffenbichler i give it a try, im abit lost what you mean by the As for the corner pixels code?
-
pfaffenbichler
preparation of document HELP
selection.select takes an Array of Arrays as the first argument.
So for the pixel at the upper left that would be [[0,0], [0,1], [1,1], [1,0]]
So for the pixel at the upper left that would be [[0,0], [0,1], [1,1], [1,0]]
-
boogotti
preparation of document HELP
pfaffenbichler wrote:selection.select takes an Array of Arrays as the first argument.
So for the pixel at the upper left that would be [[0,0], [0,1], [1,1], [1,0]]
thanks "pfaffenbichler i have tried adding the coordinates and the line of code but its coming with errors.
i have no scripting experience pls help.
not sure ohw to add this
So for the pixel at the upper left that would be [[0,0], [0,1], [1,1], [1,0]]
thanks "pfaffenbichler i have tried adding the coordinates and the line of code but its coming with errors.
i have no scripting experience pls help.
not sure ohw to add this
-
pfaffenbichler
preparation of document HELP
Selection is a property of a Document, so you would have to define that, for example
Code: Select allapp.activeDocument.selection.select([[0,0], [0,1], [1,1], [1,0]], SelectionType.EXTEND, 0, false);
This would add one pixel to an existing Selection, you would have to do the same for the other three pixels and then fill the Selection.
Code: Select allapp.activeDocument.selection.select([[0,0], [0,1], [1,1], [1,0]], SelectionType.EXTEND, 0, false);
This would add one pixel to an existing Selection, you would have to do the same for the other three pixels and then fill the Selection.
-
boogotti
preparation of document HELP
pfaffenbichler i have tried adding that selection and filling the pixel but i have a problem. Dont know if this will work.
As each document i will use the script on the width of the document will be different but the pixels need to be in the corners for each document. Will the coordinates system still work? for this?
As each document i will use the script on the width of the document will be different but the pixels need to be in the corners for each document. Will the coordinates system still work? for this?
-
pfaffenbichler
preparation of document HELP
You just need to use the document’s width and height properties.
Code: Select allvar theW = myDocument.width;
var theH = myDocument.height;
app.activeDocument.selection.select([[0,0], [0,1], [1,1], [1,0]], SelectionType.REPLACE, 0, false);
app.activeDocument.selection.select([[theW,0], [theW,1], [theW-1,1], [theW-1,0]], SelectionType.EXTEND, 0, false);
etc.
Code: Select allvar theW = myDocument.width;
var theH = myDocument.height;
app.activeDocument.selection.select([[0,0], [0,1], [1,1], [1,0]], SelectionType.REPLACE, 0, false);
app.activeDocument.selection.select([[theW,0], [theW,1], [theW-1,1], [theW-1,0]], SelectionType.EXTEND, 0, false);
etc.
-
pfaffenbichler
preparation of document HELP
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);
};
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);
};
-
boogotti
preparation of document HELP
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!
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!