@pixerate/editor 0.197.0 → 0.198.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.
@@ -1,6 +1,7 @@
1
1
  import { AdjustmentKind, AdjustmentLayer, AdjustmentParamsMap, Annotation, CreateAnnotationPayload, AspectRatio, CropBox, DepthMaskOptions, ExportOptions, ImageAdjustments, ImageDimensions, ImageEditorFit, ImageEditorOptions, ImageEditorState, ImageEditorTool, ImageTransform, ImagePoint, SerializedImageEditorState } from './types.cjs';
2
2
  import { type PathToSelectionOptions, type SelectionToPathOptions } from './selection/path.cjs';
3
3
  import { type MagneticEdgeOptions } from './selection/magnetic.cjs';
4
+ import { type ObjectTarget } from './selection/segment/grabcut.cjs';
4
5
  import { RenderOptions } from './renderer.cjs';
5
6
  import { type BlendMode } from './blend.cjs';
6
7
  import type { ImageHistogram } from './histogram.cjs';
@@ -151,6 +152,15 @@ export interface QuickSelectCommandOptions {
151
152
  /** Smoother, less blocky edges (Photoshop's Auto-Enhance). Default false. */
152
153
  enhanceEdge?: boolean;
153
154
  }
155
+ /** Options of {@link ImageEditorController.selectObject}. */
156
+ export interface SelectObjectCommandOptions {
157
+ /** How the object combines with the selection (default `replace`). */
158
+ mode?: SelectionMode;
159
+ /** Sample every layer (default true) or only the active pixel layer. */
160
+ sampleAllLayers?: boolean;
161
+ /** Smoother, less blocky edges (Auto-Enhance). Default false. */
162
+ enhanceEdge?: boolean;
163
+ }
154
164
  /** A new adjustment layer: its kind plus optional initial values and position. */
155
165
  export interface AdjustmentLayerInit<K extends AdjustmentKind = AdjustmentKind> extends AdjustmentLayerUpdate<K> {
156
166
  kind: K;
@@ -1523,6 +1533,13 @@ export declare class ImageEditorController {
1523
1533
  * one undo step. Resolves to the resulting selection.
1524
1534
  */
1525
1535
  quickSelect(strokes: ImagePoint[][], options?: QuickSelectCommandOptions): Promise<SelectionMask | null>;
1536
+ /**
1537
+ * Object Selection: the object inside `target.rect` (natural pixels; what is outside the box is
1538
+ * background) or under `target.point`, found by GrabCut (colour models of object and background
1539
+ * plus a graph cut along edges), combined with the selection by `mode` as one undo step.
1540
+ * Resolves to the resulting selection.
1541
+ */
1542
+ selectObject(target: ObjectTarget, options?: SelectObjectCommandOptions): Promise<SelectionMask | null>;
1526
1543
  /**
1527
1544
  * Supplies the pixels the selection tools sample (natural size RGBA), e.g. decoded in a worker
1528
1545
  * or in a test; `null` goes back to reading the source image. Without a canvas (Node, workers)
@@ -1,6 +1,7 @@
1
1
  import { AdjustmentKind, AdjustmentLayer, AdjustmentParamsMap, Annotation, CreateAnnotationPayload, AspectRatio, CropBox, DepthMaskOptions, ExportOptions, ImageAdjustments, ImageDimensions, ImageEditorFit, ImageEditorOptions, ImageEditorState, ImageEditorTool, ImageTransform, ImagePoint, SerializedImageEditorState } from './types.js';
2
2
  import { type PathToSelectionOptions, type SelectionToPathOptions } from './selection/path.js';
3
3
  import { type MagneticEdgeOptions } from './selection/magnetic.js';
4
+ import { type ObjectTarget } from './selection/segment/grabcut.js';
4
5
  import { RenderOptions } from './renderer.js';
5
6
  import { type BlendMode } from './blend.js';
6
7
  import type { ImageHistogram } from './histogram.js';
@@ -151,6 +152,15 @@ export interface QuickSelectCommandOptions {
151
152
  /** Smoother, less blocky edges (Photoshop's Auto-Enhance). Default false. */
152
153
  enhanceEdge?: boolean;
153
154
  }
155
+ /** Options of {@link ImageEditorController.selectObject}. */
156
+ export interface SelectObjectCommandOptions {
157
+ /** How the object combines with the selection (default `replace`). */
158
+ mode?: SelectionMode;
159
+ /** Sample every layer (default true) or only the active pixel layer. */
160
+ sampleAllLayers?: boolean;
161
+ /** Smoother, less blocky edges (Auto-Enhance). Default false. */
162
+ enhanceEdge?: boolean;
163
+ }
154
164
  /** A new adjustment layer: its kind plus optional initial values and position. */
155
165
  export interface AdjustmentLayerInit<K extends AdjustmentKind = AdjustmentKind> extends AdjustmentLayerUpdate<K> {
156
166
  kind: K;
@@ -1523,6 +1533,13 @@ export declare class ImageEditorController {
1523
1533
  * one undo step. Resolves to the resulting selection.
1524
1534
  */
1525
1535
  quickSelect(strokes: ImagePoint[][], options?: QuickSelectCommandOptions): Promise<SelectionMask | null>;
1536
+ /**
1537
+ * Object Selection: the object inside `target.rect` (natural pixels; what is outside the box is
1538
+ * background) or under `target.point`, found by GrabCut (colour models of object and background
1539
+ * plus a graph cut along edges), combined with the selection by `mode` as one undo step.
1540
+ * Resolves to the resulting selection.
1541
+ */
1542
+ selectObject(target: ObjectTarget, options?: SelectObjectCommandOptions): Promise<SelectionMask | null>;
1526
1543
  /**
1527
1544
  * Supplies the pixels the selection tools sample (natural size RGBA), e.g. decoded in a worker
1528
1545
  * or in a test; `null` goes back to reading the source image. Without a canvas (Node, workers)