UXP Toolkit
    Preparing search index...

    Represents a selected area or areas in the document. If there is no active selection, the bounds will return null. The selection is pixel-based, though 8-bit transparency is possible.

    Pixel selection targets where pixel filters are applied, or from where the histogram measurement is sourced.

    const { app, constants } = require("photoshop");
    const doc = app.activeDocument;

    await doc.selection.selectRectangle(
    {top: 50, left: 50, bottom: 100, right: 100},
    constants.SelectionType.REPLACE
    );
    doc.selection.bounds; // {{top: 50, left: 50, bottom: 100, right: 100}
    doc.selection.solid; // true

    await doc.selection.selectEllipse(
    {top: 50, left: 70, bottom: 140, right: 100},
    constants.SelectionType.EXTEND
    );
    doc.selection.bounds; // {{top: 50, left: 50, bottom: 140, right: 100}
    doc.selection.solid; // false

    Pixel selection while in Quick Mask Mode: When a user switches into Quick Mask Mode, the selection is temporarily shown as a channel instead of the "marching ants" border. While in Quick Mask Mode, new pixel selections can be made via Scripting. However, upon exiting Quick Mask Mode, the Quick Mask Channel will become the active selection.

    25.0

    Index

    Accessors

    Methods

    • Contract (shrink) the selection by the specified amount.

      If the contraction amount is greater than the selected area radius, the selected area will disappear entirely. If there are no other active selected areas, then there will be no active selection altogether.

      UI Location: Select > Modify > Contract

      Parameters

      • by: number

        The amount to contract the selection (integer in the range 1..500).

      • OptionalapplyEffectAtCanvasBounds: boolean

        By default this is false, meaning that any part of the selection that touches the bounds of the canvas will not be affected by the contraction.

      Returns Promise<void>

      await doc.selection.contract(8);
      

      25.0

    • Feather the edges of the selection by the specified amount. This softening of the selection strength is best viewed as a channel via Quick Mask Mode. Large values might make the selection disappear entirely (.bounds would return null).

      UI Location: Select > Modify > Feather

      Parameters

      • by: number

        The amount to feather the selection with (decimal in the range 0.1..1000).

      • OptionalapplyEffectAtCanvasBounds: boolean

        By default this is false, meaning that any part of the selection that touches the bounds of the canvas will not be affected by the feathering.

      Returns Promise<void>

      await doc.selection.feather(16);
      

      25.0

    • Make an elliptical selection.

      UI Location: Toolbar > Elliptical Marquee Tool

      Parameters

      • bounds: Bounds

        The bounds of the selection, as an object with {top, left, bottom, right} properties.

      • Optionalmode: SelectionType

        The selection behavior when a selection already exists. Default: SelectionType.REPLACE

      • Optionalfeather: number

        The amount of feathering in pixels to apply to the selection (decimal in the range 0..1000, default: 0)

      • OptionalantiAlias: boolean

        If true, anti-aliasing is applied to the selection (default: true)

      Returns Promise<void>

      await doc.selection.selectEllipse({top: 0, left: 0, bottom: 100, right: 100});
      

      25.0

    • Make a polygonal selection.

      UI Location: Toolbar > Polygonal Lasso Tool

      Parameters

      • points: { x: number; y: number }[]

        The points to select as an array of objects with {x, y} properties.

      • Optionalmode: SelectionType

        The selection behavior when a selection already exists. Default: SelectionType.REPLACE

      • Optionalfeather: number

        The amount of feathering in pixels to apply to the selection (decimal in the range 0..1000, default: 0)

      • OptionalantiAlias: boolean

        If true, anti-aliasing is applied to the selection (default: true)

      Returns Promise<void>

      await doc.selection.selectPolygon([
      {x: 50, y: 10},
      {x: 100, y: 90},
      {x: 10, y: 40}
      ]);

      25.0

    • Make a rectangular selection.

      UI Location: Toolbar > Rectangular Marquee Tool

      Parameters

      • bounds: Bounds

        The bounds of the selection, as an object with {top, left, bottom, right} properties.

      • Optionalmode: SelectionType

        The selection behavior when a selection already exists. Default: SelectionType.REPLACE

      • Optionalfeather: number

        The amount of feathering in pixels to apply to the selection (decimal in the range 0..1000, default: 0)

      • OptionalantiAlias: boolean

        If true, anti-aliasing is applied to the selection (default: true)

      Returns Promise<void>

      await doc.selection.selectRectangle(
      {top: 0, left: 0, bottom: 100, right: 100},
      Constants.SelectionType.REPLACE,
      10
      );

      25.0

    • Reduce patchiness and smooth sharp corners and jagged lines in the selection. Smooth will also remove isolated groups of pixels that are smaller than the given radius. This effect is useful for cleaning up stray pixels from color-based selections.

      Large values might make the selection disappear entirely (.bounds would return null).

      UI Location: Select > Modify > Smooth...

      Parameters

      • radius: number

        The sample radius in pixels (integer in the range 1..500)

      • OptionalapplyEffectAtCanvasBounds: boolean

        By default this is false, meaning that any part of the selection that touches the bounds of the canvas will not be affected by the smoothing.

      Returns Promise<void>

      await doc.selection.smooth(32);
      

      25.0