Guides between pixels
Hi all,
I'd like to know if its possible to create a script that place a vertical guide in between pixels like in the example below:
before:

after:
This is a png files with just one layer.
Is that possible?
Thanks!
Hi all,
I'd like to know if its possible to create a script that place a vertical guide in between pixels like in the example below:
before:

after:
This is a png files with just one layer.
Is that possible?
Thanks!
If your objects are located on a transparent background and are arranged sequentially horizontally (in the middle of the height of the document),
then you can try this script.
Not very fast. ![]()
preferences.rulerUnits = Units.PIXELS;
var doc = activeDocument;
var h = doc.height.value;
var w = doc.width.value;
var step = w/100;
var b = new Array();
magicwand(0, h/2);
b.push(doc.selection.bounds);
for (var i = step; i < w; i+= step)
{
magicwand(i, h/2);
if (doc.selection.bounds[0] != b[b.length-1][0] && doc.selection.bounds[0] != b[0][0]) b.push(doc.selection.bounds);
}
doc.selection.deselect();
doc.guides.removeAll();
for (var i = 1; i < b.length-1; i++)
{
doc.guides.add(Direction.VERTICAL, (b[2]+b[i+1][0])/2);
}
////////////////////////////////////////////////////////////////////////////////////////////
function magicwand(x,y)
{
try {
var d = new ActionDescriptor();
var r = new ActionReference();
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
d.putReference(stringIDToTypeID("null"), r);
var d1 = new ActionDescriptor();
d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), x);
d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), y);
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("point"), d1);
d.putInteger(stringIDToTypeID("tolerance"), 255);
d.putBoolean(stringIDToTypeID("antiAlias"), false);
d.putBoolean(stringIDToTypeID("merged"), true);
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
return true;
}
catch (e) { throw(e); }
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.