TacoMakerMan TacoMakerMan - 2 months ago 16
Javascript Question

How do I flip a selected area of a layer using JavaScript script in Photoshop?

So I am writing a script for Photoshop (using JavaScript) and I want it to select a marquee area and then invert the colors of that area and then flip that area upside down (vertically).

I tried doing:

doc.artLayers["Layer 1"].resize(1, doc.height * -1)


However this transforms the entire layer instead of just the selected area and adding
.selection
in there just returns an error. Any help would be great, thanks.

Answer

It's easier just using the ScriptListener:

dir = "Hrzn"; // for horizontal
// dir = "Vrtc"; // for vertical
var desc = new ActionDescriptor();
desc.putEnumerated( charIDToTypeID('Axis'), charIDToTypeID('Ornt'),   charIDToTypeID(dir) );
executeAction( charIDToTypeID('Flip'), desc, DialogModes.NO );