@pixerate/editor 0.198.0 → 0.200.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.
@@ -2,6 +2,7 @@ import { AdjustmentKind, AdjustmentLayer, AdjustmentParamsMap, Annotation, Creat
2
2
  import { type PathToSelectionOptions, type SelectionToPathOptions } from './selection/path.cjs';
3
3
  import { type MagneticEdgeOptions } from './selection/magnetic.cjs';
4
4
  import { type ObjectTarget } from './selection/segment/grabcut.cjs';
5
+ import { type FocusAreaOptions } from './selection/segment/focus.cjs';
5
6
  import { RenderOptions } from './renderer.cjs';
6
7
  import { type BlendMode } from './blend.cjs';
7
8
  import type { ImageHistogram } from './histogram.cjs';
@@ -152,6 +153,13 @@ export interface QuickSelectCommandOptions {
152
153
  /** Smoother, less blocky edges (Photoshop's Auto-Enhance). Default false. */
153
154
  enhanceEdge?: boolean;
154
155
  }
156
+ /** Options of {@link ImageEditorController.selectFocusArea}. */
157
+ export interface FocusAreaCommandOptions extends FocusAreaOptions {
158
+ /** How the area combines with the selection (default `replace`). */
159
+ mode?: SelectionMode;
160
+ /** Sample every layer (default true) or only the active pixel layer. */
161
+ sampleAllLayers?: boolean;
162
+ }
155
163
  /** Options of {@link ImageEditorController.selectObject}. */
156
164
  export interface SelectObjectCommandOptions {
157
165
  /** How the object combines with the selection (default `replace`). */
@@ -674,7 +682,7 @@ export declare class ImageEditorController {
674
682
  * or those drawn while a result was rendering, once it is in. A cache refresh: no undo step.
675
683
  */
676
684
  private refreshEffectSurfaces;
677
- /** The registered segmentation provider, or `null` (then `selectSubject` is unavailable). */
685
+ /** The registered segmentation provider, or `null` (then `selectSubject` finds the most salient subject without a model). */
678
686
  get segmentationProvider(): SegmentationProvider | null;
679
687
  /** Registers (or with `null` removes) the segmentation provider. Not an edit: no undo step. */
680
688
  setSegmentationProvider(provider: SegmentationProvider | null): void;
@@ -1540,6 +1548,15 @@ export declare class ImageEditorController {
1540
1548
  * Resolves to the resulting selection.
1541
1549
  */
1542
1550
  selectObject(target: ObjectTarget, options?: SelectObjectCommandOptions): Promise<SelectionMask | null>;
1551
+ /**
1552
+ * Select › Focus Area: selects the parts of the image that are in focus (fine detail above the
1553
+ * image's noise), fitted to its edges, combined with the selection by `mode` as one undo step.
1554
+ * Resolves to the selection and the noise level measured (σ of luminance in levels).
1555
+ */
1556
+ selectFocusArea(options?: FocusAreaCommandOptions): Promise<{
1557
+ selection: SelectionMask | null;
1558
+ noiseLevel: number;
1559
+ }>;
1543
1560
  /**
1544
1561
  * Supplies the pixels the selection tools sample (natural size RGBA), e.g. decoded in a worker
1545
1562
  * or in a test; `null` goes back to reading the source image. Without a canvas (Node, workers)
@@ -1613,19 +1630,25 @@ export declare class ImageEditorController {
1613
1630
  * Select › Subject: asks the segmentation provider for the objects matching `target` ("the
1614
1631
  * dog", "the sky") in the flattened image and selects their shapes, combined with the
1615
1632
  * selection by `mode`, as one undo step. Returns what was found (labels and bounds in natural
1616
- * pixels); an empty list leaves the selection as it was. Throws without a provider.
1633
+ * pixels); an empty list leaves the selection as it was. Without a provider, the subject that
1634
+ * stands out most is found classically (superpixels, saliency, Otsu, GrabCut): `target` can't
1635
+ * choose it, and `method: 'saliency'` and a `note` say so.
1617
1636
  */
1618
- selectSubject(target: string, options?: SelectionCommandOptions & {
1637
+ selectSubject(target?: string, options?: SelectionCommandOptions & {
1619
1638
  maxSegments?: number;
1620
1639
  signal?: AbortSignal;
1621
1640
  /** Called with the outlines found (image pixels; a mask-only result's bounds) before the selection changes, e.g. to trace them with an agent's cursor. */
1622
1641
  beforeApply?: (outlines: ImagePoint[][]) => void | Promise<void>;
1642
+ /** Without a model: smoother, less blocky edges (Auto-Enhance). */
1643
+ enhanceEdge?: boolean;
1623
1644
  }): Promise<{
1624
1645
  segments: {
1625
1646
  label: string;
1626
1647
  bounds: CropBox | null;
1627
1648
  score?: number;
1628
1649
  }[];
1650
+ method: 'model' | 'saliency';
1651
+ note?: string;
1629
1652
  }>;
1630
1653
  /** Quick Mask view (tints the unselected area). View state: no undo step. */
1631
1654
  setQuickMask(on: boolean): void;
@@ -2,6 +2,7 @@ import { AdjustmentKind, AdjustmentLayer, AdjustmentParamsMap, Annotation, Creat
2
2
  import { type PathToSelectionOptions, type SelectionToPathOptions } from './selection/path.js';
3
3
  import { type MagneticEdgeOptions } from './selection/magnetic.js';
4
4
  import { type ObjectTarget } from './selection/segment/grabcut.js';
5
+ import { type FocusAreaOptions } from './selection/segment/focus.js';
5
6
  import { RenderOptions } from './renderer.js';
6
7
  import { type BlendMode } from './blend.js';
7
8
  import type { ImageHistogram } from './histogram.js';
@@ -152,6 +153,13 @@ export interface QuickSelectCommandOptions {
152
153
  /** Smoother, less blocky edges (Photoshop's Auto-Enhance). Default false. */
153
154
  enhanceEdge?: boolean;
154
155
  }
156
+ /** Options of {@link ImageEditorController.selectFocusArea}. */
157
+ export interface FocusAreaCommandOptions extends FocusAreaOptions {
158
+ /** How the area combines with the selection (default `replace`). */
159
+ mode?: SelectionMode;
160
+ /** Sample every layer (default true) or only the active pixel layer. */
161
+ sampleAllLayers?: boolean;
162
+ }
155
163
  /** Options of {@link ImageEditorController.selectObject}. */
156
164
  export interface SelectObjectCommandOptions {
157
165
  /** How the object combines with the selection (default `replace`). */
@@ -674,7 +682,7 @@ export declare class ImageEditorController {
674
682
  * or those drawn while a result was rendering, once it is in. A cache refresh: no undo step.
675
683
  */
676
684
  private refreshEffectSurfaces;
677
- /** The registered segmentation provider, or `null` (then `selectSubject` is unavailable). */
685
+ /** The registered segmentation provider, or `null` (then `selectSubject` finds the most salient subject without a model). */
678
686
  get segmentationProvider(): SegmentationProvider | null;
679
687
  /** Registers (or with `null` removes) the segmentation provider. Not an edit: no undo step. */
680
688
  setSegmentationProvider(provider: SegmentationProvider | null): void;
@@ -1540,6 +1548,15 @@ export declare class ImageEditorController {
1540
1548
  * Resolves to the resulting selection.
1541
1549
  */
1542
1550
  selectObject(target: ObjectTarget, options?: SelectObjectCommandOptions): Promise<SelectionMask | null>;
1551
+ /**
1552
+ * Select › Focus Area: selects the parts of the image that are in focus (fine detail above the
1553
+ * image's noise), fitted to its edges, combined with the selection by `mode` as one undo step.
1554
+ * Resolves to the selection and the noise level measured (σ of luminance in levels).
1555
+ */
1556
+ selectFocusArea(options?: FocusAreaCommandOptions): Promise<{
1557
+ selection: SelectionMask | null;
1558
+ noiseLevel: number;
1559
+ }>;
1543
1560
  /**
1544
1561
  * Supplies the pixels the selection tools sample (natural size RGBA), e.g. decoded in a worker
1545
1562
  * or in a test; `null` goes back to reading the source image. Without a canvas (Node, workers)
@@ -1613,19 +1630,25 @@ export declare class ImageEditorController {
1613
1630
  * Select › Subject: asks the segmentation provider for the objects matching `target` ("the
1614
1631
  * dog", "the sky") in the flattened image and selects their shapes, combined with the
1615
1632
  * selection by `mode`, as one undo step. Returns what was found (labels and bounds in natural
1616
- * pixels); an empty list leaves the selection as it was. Throws without a provider.
1633
+ * pixels); an empty list leaves the selection as it was. Without a provider, the subject that
1634
+ * stands out most is found classically (superpixels, saliency, Otsu, GrabCut): `target` can't
1635
+ * choose it, and `method: 'saliency'` and a `note` say so.
1617
1636
  */
1618
- selectSubject(target: string, options?: SelectionCommandOptions & {
1637
+ selectSubject(target?: string, options?: SelectionCommandOptions & {
1619
1638
  maxSegments?: number;
1620
1639
  signal?: AbortSignal;
1621
1640
  /** Called with the outlines found (image pixels; a mask-only result's bounds) before the selection changes, e.g. to trace them with an agent's cursor. */
1622
1641
  beforeApply?: (outlines: ImagePoint[][]) => void | Promise<void>;
1642
+ /** Without a model: smoother, less blocky edges (Auto-Enhance). */
1643
+ enhanceEdge?: boolean;
1623
1644
  }): Promise<{
1624
1645
  segments: {
1625
1646
  label: string;
1626
1647
  bounds: CropBox | null;
1627
1648
  score?: number;
1628
1649
  }[];
1650
+ method: 'model' | 'saliency';
1651
+ note?: string;
1629
1652
  }>;
1630
1653
  /** Quick Mask view (tints the unselected area). View state: no undo step. */
1631
1654
  setQuickMask(on: boolean): void;