TacoMakerMan TacoMakerMan - 1 year ago 136
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
in there just returns an error. Any help would be great, thanks.

Answer Source

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 );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download