Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Flip and invert colors of selected area - Javascript for Photoshop

Explorer ,
Apr 17, 2016 Apr 17, 2016

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)

TOPICS
Actions and scripting
3.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 17, 2016 Apr 17, 2016

I haven't checked your other lines, but your invert line should be:

docRef.activeLayer.invert()

Translate
Adobe
Community Expert ,
Apr 17, 2016 Apr 17, 2016

I haven't checked your other lines, but your invert line should be:

docRef.activeLayer.invert()

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 17, 2016 Apr 17, 2016

Thank You

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2016 Apr 17, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 19, 2016 Apr 19, 2016
LATEST

Thank You! It's so weird that it has to be so complicated ].

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines