@pixerate/editor 0.204.0 → 0.206.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,7 @@ import { type GrowSimilarOptions, type ColorRangeOptions, type ColorRangePreset,
13
13
  import { type SelectionModifyOp } from './selection/modify.cjs';
14
14
  import { type SegmentationProvider } from './selection/segmentation.cjs';
15
15
  import { type RefineEdgeParams } from './selection/refine.cjs';
16
+ import { type RefineEdit } from './selection/refine-edits.cjs';
16
17
  import { type LayerMaskProps } from './selection/layer-mask.cjs';
17
18
  import { type AlphaChannel } from './selection/channels.cjs';
18
19
  import type { AdjustmentLayerMask } from './types.cjs';
@@ -161,6 +162,18 @@ export interface FocusAreaCommandOptions extends FocusAreaOptions {
161
162
  /** Sample every layer (default true) or only the active pixel layer. */
162
163
  sampleAllLayers?: boolean;
163
164
  }
165
+ /** Where Select and Mask puts its result (Photoshop's Output To). */
166
+ export type RefineOutput = 'selection' | 'layer-mask' | 'new-layer' | 'new-layer-with-mask';
167
+ /** What {@link ImageEditorController.refineSelectionTo} made. */
168
+ export interface RefineOutputResult {
169
+ output: RefineOutput;
170
+ /** The layer the output came from (all but `selection`). */
171
+ layerId?: string;
172
+ /** The layer it made (`new-layer`, `new-layer-with-mask`). */
173
+ newLayerId?: string;
174
+ /** How the edge was refined: by colour, or with the segmentation model (object aware). */
175
+ refineMode: 'color' | 'object';
176
+ }
164
177
  /** Options of {@link ImageEditorController.selectSky}. */
165
178
  export interface SkyCommandOptions extends SkyOptions {
166
179
  /** With a segmentation provider set, ask it for the sky (default true); false finds it classically. */
@@ -1632,6 +1645,34 @@ export declare class ImageEditorController {
1632
1645
  * to the image's edges with a guided filter, then smooth / feather / contrast / shift edge.
1633
1646
  */
1634
1647
  refineSelection(params: RefineEdgeParams, options?: SampleOptions): Promise<boolean>;
1648
+ /**
1649
+ * Select and Mask's output: refines the selection with `params`, then puts the result where
1650
+ * `output` says, as one undo step:
1651
+ * - `selection`: the refined selection;
1652
+ * - `layer-mask`: a mask on the layer (`layerId`, default the active one), then deselects;
1653
+ * - `new-layer`: a new layer of the layer's selected pixels (Layer via Copy), the source hidden;
1654
+ * - `new-layer-with-mask`: a copy of the layer masked by the selection, the source hidden.
1655
+ * `decontaminate` (0..100, new-layer outputs only) replaces the old background's colour in the
1656
+ * soft edge with the subject's own (see `decontaminateColors`).
1657
+ *
1658
+ * `edits` are the workspace's strokes, applied first in order (Quick Selection, Brush and
1659
+ * Refine Edge Brush; see `RefineEdit`); with them, an empty selection is a valid start.
1660
+ * `refineMode: 'object'` asks the segmentation provider for the object in the selection's
1661
+ * bounds and refines from its outline, kept to near the selection's edge.
1662
+ */
1663
+ refineSelectionTo(params: RefineEdgeParams, output?: RefineOutput, options?: SampleOptions & {
1664
+ layerId?: string;
1665
+ decontaminate?: number;
1666
+ edits?: RefineEdit[];
1667
+ refineMode?: 'color' | 'object';
1668
+ signal?: AbortSignal;
1669
+ }): Promise<RefineOutputResult>;
1670
+ /**
1671
+ * Decontaminate Colors along the soft edge of `coverage`: the colours are estimated from the
1672
+ * source layer (whose background is still there) and written into layer `id`'s RGB, keeping
1673
+ * its alpha.
1674
+ */
1675
+ private decontaminateLayer;
1635
1676
  /**
1636
1677
  * Loads a selection from a mask image (an AI segmentation, a saved mask): a data URL / URL or
1637
1678
  * RGBA pixels, by luminance (white = selected) or a channel. Any size; it is resampled.
@@ -13,6 +13,7 @@ import { type GrowSimilarOptions, type ColorRangeOptions, type ColorRangePreset,
13
13
  import { type SelectionModifyOp } from './selection/modify.js';
14
14
  import { type SegmentationProvider } from './selection/segmentation.js';
15
15
  import { type RefineEdgeParams } from './selection/refine.js';
16
+ import { type RefineEdit } from './selection/refine-edits.js';
16
17
  import { type LayerMaskProps } from './selection/layer-mask.js';
17
18
  import { type AlphaChannel } from './selection/channels.js';
18
19
  import type { AdjustmentLayerMask } from './types.js';
@@ -161,6 +162,18 @@ export interface FocusAreaCommandOptions extends FocusAreaOptions {
161
162
  /** Sample every layer (default true) or only the active pixel layer. */
162
163
  sampleAllLayers?: boolean;
163
164
  }
165
+ /** Where Select and Mask puts its result (Photoshop's Output To). */
166
+ export type RefineOutput = 'selection' | 'layer-mask' | 'new-layer' | 'new-layer-with-mask';
167
+ /** What {@link ImageEditorController.refineSelectionTo} made. */
168
+ export interface RefineOutputResult {
169
+ output: RefineOutput;
170
+ /** The layer the output came from (all but `selection`). */
171
+ layerId?: string;
172
+ /** The layer it made (`new-layer`, `new-layer-with-mask`). */
173
+ newLayerId?: string;
174
+ /** How the edge was refined: by colour, or with the segmentation model (object aware). */
175
+ refineMode: 'color' | 'object';
176
+ }
164
177
  /** Options of {@link ImageEditorController.selectSky}. */
165
178
  export interface SkyCommandOptions extends SkyOptions {
166
179
  /** With a segmentation provider set, ask it for the sky (default true); false finds it classically. */
@@ -1632,6 +1645,34 @@ export declare class ImageEditorController {
1632
1645
  * to the image's edges with a guided filter, then smooth / feather / contrast / shift edge.
1633
1646
  */
1634
1647
  refineSelection(params: RefineEdgeParams, options?: SampleOptions): Promise<boolean>;
1648
+ /**
1649
+ * Select and Mask's output: refines the selection with `params`, then puts the result where
1650
+ * `output` says, as one undo step:
1651
+ * - `selection`: the refined selection;
1652
+ * - `layer-mask`: a mask on the layer (`layerId`, default the active one), then deselects;
1653
+ * - `new-layer`: a new layer of the layer's selected pixels (Layer via Copy), the source hidden;
1654
+ * - `new-layer-with-mask`: a copy of the layer masked by the selection, the source hidden.
1655
+ * `decontaminate` (0..100, new-layer outputs only) replaces the old background's colour in the
1656
+ * soft edge with the subject's own (see `decontaminateColors`).
1657
+ *
1658
+ * `edits` are the workspace's strokes, applied first in order (Quick Selection, Brush and
1659
+ * Refine Edge Brush; see `RefineEdit`); with them, an empty selection is a valid start.
1660
+ * `refineMode: 'object'` asks the segmentation provider for the object in the selection's
1661
+ * bounds and refines from its outline, kept to near the selection's edge.
1662
+ */
1663
+ refineSelectionTo(params: RefineEdgeParams, output?: RefineOutput, options?: SampleOptions & {
1664
+ layerId?: string;
1665
+ decontaminate?: number;
1666
+ edits?: RefineEdit[];
1667
+ refineMode?: 'color' | 'object';
1668
+ signal?: AbortSignal;
1669
+ }): Promise<RefineOutputResult>;
1670
+ /**
1671
+ * Decontaminate Colors along the soft edge of `coverage`: the colours are estimated from the
1672
+ * source layer (whose background is still there) and written into layer `id`'s RGB, keeping
1673
+ * its alpha.
1674
+ */
1675
+ private decontaminateLayer;
1635
1676
  /**
1636
1677
  * Loads a selection from a mask image (an AI segmentation, a saved mask): a data URL / URL or
1637
1678
  * RGBA pixels, by luminance (white = selected) or a channel. Any size; it is resampled.