I just want to flip a layer vertically

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

My old boots

I just want to flip a layer vertically

Post by My old boots »

Hi I am copying a section of my image and pasting it as a new layer. I am stuck on how do I flip the layer ?

The only flip I can find in the documentation is flipCanvas(). This is no use as it flips the whole image.

If I have to use script listener then I will, but I can't believe something this fundamental is not native to JSX

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Paul MR

I just want to flip a layer vertically

Post by Paul MR »

Yup, scriptlistener....
Code: Select allflipLayer(0); //Flip Horizontal
flipLayer(1); //Flip Vertical

function flipLayer(type) {
   if(type == 0) pos ='Hrzn';
   if(type == 1) pos ='Vrtc';
    var desc = new ActionDescriptor();
    desc.putEnumerated( charIDToTypeID('Axis'), charIDToTypeID('Ornt'), charIDToTypeID(pos) );
   executeAction( charIDToTypeID('Flip'), desc, DialogModes.NO );
};
My old boots

I just want to flip a layer vertically

Post by My old boots »

Thanks.

I wonder why they don't have that as an artLayer method.
Mike Hale

I just want to flip a layer vertically

Post by Mike Hale »

I don't think that there is anything 'wrong' with using Action Manager(scriptlistener). Often it is the only way to script some tasks and I think that it's closer to Photoshop's native code than the scripting languages.

But in this case you can use the DOM.

Code: Select allapp.activeDocument.activeLayer.resize(new UnitValue(100,'%'),new UnitValue(-100,'%'));
My old boots

I just want to flip a layer vertically

Post by My old boots »

LOL I'd never have thought to size it by -100% vertically.

Thanks again
applezap

I just want to flip a layer vertically

Post by applezap »

Sorry to revive an old thread. This works great to flip vertically, but what if I wanted to flip horizontally. I get the -100 thing, but how would you specify that it should be in x instead of y?

Thanks
Mike Hale

I just want to flip a layer vertically

Post by Mike Hale »

The first argument in layer.resize is width, the second height. To flip horizontally
Code: Select allapp.activeDocument.activeLayer.resize(new UnitValue(-100,'%'),new UnitValue(100,'%'));
applezap

I just want to flip a layer vertically

Post by applezap »

It seems so obvious now that you say it. Thank you!