Skip to main content
Participant
October 13, 2008
Question

How to create a elliptical selection?

  • October 13, 2008
  • 5 replies
  • 1033 views
I am trying to create a JavaScript to create a elliptical vignette. I am somewhat new to scripting, I have done some basic scripting, but nothing to this degree. The first step is to create a new layer, I am sure that will be easy to find an example of in the documentation. The second part is a bit harder...<br /><br />I want to make an elliptical selection. Lets keep things simple and assume the image is 800x1000 and the ellipse comes in 100 pixels, so it is 600x800.<br /><br />A: How do I go about creating this selection?<br /><br />Another thing that I don't think is too hard, but might be... I want to turn this selected layer int a layer mask (<Alt> and click the Add Layers Mask icon in the Layers palette). How might I do that?<br /><br />Sam Carleton<br />http://www.photoparata.com
This topic has been closed for replies.

5 replies

Participant
November 30, 2008
Simple scripts for the image current aspect ratio to select elliptical vignette are in my image visualization package example here http://www.mouseprints.net/old/dpr/Examples/
Readme and download here these will work in cs2 http://www.mouseprints.net/old/dpr/ReadMe.html
Participant
November 30, 2008
If you do not have CS3 here is the to code to set the selection. Photoshop Scripting methods had no way that I could see to set an elliptical selection. So I had to resort to using the Script Listener to see how to do it with the action manager. I created a function to set a selection with shape rectangle or ellipse you need to calculate where the top left and bottom right corners are....

/* SetMarqueeSelection function from Scriptlistner plugin
// ========================================================================== */
function setMarqueeSelection(x1, y1, x2, y2, type, shape, feather, antiAlias) {
var SelectionType =null;
if (type ==null) { var SelectionType = "setd" }
if (type ==diminish) { var SelectionType = "SbtF" }
if (type ==extend) { var SelectionType = "AddT" }
if (type ==intersect) { var SelectionType = "IntW" }
if (type ==replace) { var SelectionType = "setd" }

var id3 = charIDToTypeID( SelectionType );
var desc2 = new ActionDescriptor();
var id4 = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var id5 = charIDToTypeID( "Chnl" );
var id6 = charIDToTypeID( "fsel" );
ref1.putProperty( id5, id6 );
desc2.putReference( id4, ref1 );
var id7 = charIDToTypeID( "T " );
var desc3 = new ActionDescriptor();
var id8 = charIDToTypeID( "Top " );
var id9 = charIDToTypeID( "#Pxl" );
desc3.putUnitDouble( id8, id9, y1 );
var id10 = charIDToTypeID( "Left" );
var id11 = charIDToTypeID( "#Pxl" );
desc3.putUnitDouble( id10, id11, x1 );
var id12 = charIDToTypeID( "Btom" );
var id13 = charIDToTypeID( "#Pxl" );
desc3.putUnitDouble( id12, id13, y2 );
var id14 = charIDToTypeID( "Rght" );
var id15 = charIDToTypeID( "#Pxl" );
desc3.putUnitDouble( id14, id15, x2 );
var id16 = charIDToTypeID( shape );
desc2.putObject( id7, id16, desc3 );
var id17 = charIDToTypeID( "Fthr" );
var id18 = charIDToTypeID( "#Pxl" );
desc2.putUnitDouble( id17, id18, feather );
var id19 = charIDToTypeID( "AntA" );
desc2.putBoolean( id19, antiAlias );
executeAction( id3, desc2, DialogModes.NO );
}
Participant
November 30, 2008
If you have CS3 you can download my Standard Crop Actions & Scripts from Adobe exchange it has a Script that will do what you want. The script is a Photoshop Plug-in and can be recorded is actions. Script Plug-in support was added in CS3 that is why CS3 is required. AspectRatioSelection.jsx can select any aspect ratio selection rectangle or oval. it can be set to any of the selection modes replace add subtract intersect be centered or to the left and have a 25% border. If recorded in an action the values used in the scripts Dialog will be recorded and used when the action is played. The script was modeled after Adobe FitImage script plug-in. I also fixed a small bug in FitImage and made an enhancement to it on my system.
Known Participant
October 13, 2008
or record the making an ellipse path using script listener from that you could record going to vector mask or create selection and go to a regular mask.
Inchindown
Inspiring
October 13, 2008
I have a script on my site to add an elliptical matte to an image. This script creates an elliptical selection and might help with what you want to do. Feel free to edit it to suit you needs.

http://www.georgedingwall.co.uk/pages/Downloads.html

It's the first one on the page.