Copy link to clipboard
Copied
So I am writing a script for Photoshop using Javascript and I have a selection that I want to flip vertically and then invert the colors of a layer, however I can't seem to find a command on how to do this.
Here's what I've tried:
docRef.selection.select(shapeRef)
docRef.activeArtLayer.Invert()
docRef.activeArtLayer.flip(Direction.VERTICAL)
I haven't checked your other lines, but your invert line should be:
docRef.activeLayer.invert()
Copy link to clipboard
Copied
I haven't checked your other lines, but your invert line should be:
docRef.activeLayer.invert()
Copy link to clipboard
Copied
Thank You
Copy link to clipboard
Copied
This answers Chuck Uebele​ before
var docRef = app.activeDocument;
docRef.activeLayer.invert();
This will flip the active layer (a code IMHO written by Paul Riggott)
FlipLayer('Vrtc');
function FlipLayer(direction) {
// direction = "Vrtc" or "Hrzn"
function cTID(s) { return app.charIDToTypeID(s) };
function sTID(s) { return app.stringIDToTypeID(s) };
var desc01 = new ActionDescriptor();
var ref01 = new ActionReference(); ref01.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt') );
desc01.putReference(cTID('null'), ref01);
desc01.putEnumerated(cTID('Axis'), cTID('Ornt'), cTID(direction));
executeAction(cTID('Flip'), desc01, DialogModes.NO);
}
And this will set your (rectangle) selection (the values are hardcoded)
var shapeRef = [[0, 0], [0, 150], [200, 150], [200, 0]];
docRef.selection.select (shapeRef);
Have fun
Copy link to clipboard
Copied
Thank You! It's so weird that it has to be so complicated ].
Find more inspiration, events, and resources on the new Adobe Community
Explore Now