[FIXED] Photoshop -Skript – Verwandeln Sie eine rechteckige Auswahl in einen ovalen

Ausgabe

Ich habe ein Problem, das ich nicht lösen kann.

Ich habe eine rechteckige Auswahl (die Größe spielt keine Rolle), die ich mit einem Skript in elliptisch umwandeln muss.


Ich möchte, dass die elliptische Auswahl die gleiche Größe und Position wie die rechteckige hat.
Ich habe es geschafft, dieses Skript zusammenzustellen:

    (NAR = new ActionReference).putProperty (stringIDToTypeID ("channel"), stringIDToTypeID ("selection"));
    (NAD = new ActionDescriptor).putReference (stringIDToTypeID ("null"), NAR);
    (NAD2 = new ActionDescriptor).putUnitDouble (stringIDToTypeID ("top"), stringIDToTypeID ("distanceUnit"), app.activeDocument.selection.bounds[1]);
    NAD2.putUnitDouble (stringIDToTypeID ("left"), stringIDToTypeID ("distanceUnit"), app.activeDocument.selection.bounds[0]);
    NAD2.putUnitDouble (stringIDToTypeID ("bottom"), stringIDToTypeID ("distanceUnit"), app.activeDocument.selection.bounds[3]);
    NAD2.putUnitDouble (stringIDToTypeID ("right"), stringIDToTypeID ("distanceUnit"), app.activeDocument.selection.bounds[2]);
    NAD.putObject (stringIDToTypeID ("to"), stringIDToTypeID ("ellipse"), NAD2);
    NAD.putBoolean (stringIDToTypeID ("antiAlias"), true);
    executeAction (stringIDToTypeID ("set"), NAD, DialogModes.NO);

Das Skript erstellt eine elliptische Auswahl mit denselben Grenzen wie die vorhandene rechteckige Auswahl.

Das Problem besteht darin, dass der letzte Takt zu klein ist und an eine andere Stelle außerhalb der Dokumentränder verschoben wurde.


Ich habe bereits versucht, das Dokument mit 72 DPI ohne Resampling zu konvertieren, aber es gibt mir immer noch nicht die richtige Größe.


Zur Verdeutlichung hänge ich ein Bild an.

Bild

Hat jemand Ideen?

Lösung

Dies ist zu lang und hässlich, aber es ändert Ihre Auswahl in eine Ellipse:

// Switch off any dialog boxes
displayDialogs = DialogModes.ALL; // OFF


var sb = selection_bounds(); // LRBT

selectThis(sb[0], sb[1], sb[2], sb[3], "oval");


// Set Display Dialogs back to normal
displayDialogs = DialogModes.ALL; // NORMAL


// function SELECT THIS(top, left, right, bottom, ellipse or rect [default], antialias [default] )
// --------------------------------------------------------
function selectThis(top, left, right, bottom, shape, aa)
{
    // =======================================================
    var id1 = charIDToTypeID( "setd" );
    var desc1 = new ActionDescriptor();
    var id2 = charIDToTypeID( "null" );
    var ref1 = new ActionReference();
    var id3 = charIDToTypeID( "Chnl" );
    var id4 = charIDToTypeID( "fsel" );
    ref1.putProperty( id3, id4 );
    desc1.putReference( id2, ref1 );
    var id5 = charIDToTypeID( "T   " );
    var desc2 = new ActionDescriptor();
    var id6 = charIDToTypeID( "Top " );
    var id7 = charIDToTypeID( "#Pxl" );
    desc2.putUnitDouble( id6, id7, top );
    var id8 = charIDToTypeID( "Left" );
    var id9 = charIDToTypeID( "#Pxl" );
    desc2.putUnitDouble( id8, id9, left );
    var id10 = charIDToTypeID( "Btom" );
    var id11 = charIDToTypeID( "#Pxl" );
    desc2.putUnitDouble( id10, id11, bottom );
    var id12 = charIDToTypeID( "Rght" );
    var id13 = charIDToTypeID( "#Pxl" );
    desc2.putUnitDouble( id12, id13, right );


    if (shape == "Elps" || shape == "oval")
    {
        var id14 = charIDToTypeID( "Elps" );
        desc1.putObject( id5, id14, desc2 );
        var id15 = charIDToTypeID( "AntA" );
        if (aa == true || aa == undefined)
        {
            desc1.putBoolean( id15, true );
        }
        else
        {
            desc1.putBoolean( id15, false );
        }
    }
    else
    {
        var id16 = charIDToTypeID( "Rctn" );
        desc1.putObject( id5, id16, desc2 );
    }

    executeAction( id1, desc1, DialogModes.NO );

}




function selection_bounds()
{
  try
  {
    var x = parseFloat(app.activeDocument.selection.bounds[0]);
    var y = parseFloat(app.activeDocument.selection.bounds[1]);
    var x1 = parseFloat(app.activeDocument.selection.bounds[2]);
    var y1 = parseFloat(app.activeDocument.selection.bounds[3]);

    // var selectionBounds = [x, x1, y, y1]; // LRBT
    var selectionBounds = [y, x, x1, y1];    // TLBR

    return selectionBounds;

  }

  catch(eek)
  {
    return undefined;
  }
}

Ich habe versucht, Ihren Code aufzuheben, aber ohne Erfolg. Ich habe jedoch festgestellt, dass die charIDToTypeID nicht aus vier Buchstaben besteht. dh “oben sollte “Oben” sein, “unten sollte “Btom” sein, aber Adobe hat das möglicherweise geändert.


Beantwortet von –
Ghoul Fool


Antwort geprüft von –
Marie Seifert (FixError Admin)

0 Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like