@pixerate/editor 0.213.0 → 0.214.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.
@@ -0,0 +1,70 @@
1
+ /**
2
+ * A measured report on a mask's edge (`inspect_mask_edge`), so an agent can check a selection or
3
+ * a mask without looking at it: halo (old background left just inside the edge), how much of the
4
+ * edge sits on the image's own edges, how jagged the outline is, how soft it is, holes and stray
5
+ * islands, and the worst places to look at. Read-only; works in the mask's bounds.
6
+ */
7
+ import type { CropBox } from '../types.cjs';
8
+ import type { PixelBuffer, SelectionMask } from './mask.cjs';
9
+ export interface InspectMaskEdgeOptions {
10
+ /** Holes and islands smaller than this many pixels are left out (default 16). */
11
+ minArea?: number;
12
+ }
13
+ /** A hole or island: its area in pixels and bounds. */
14
+ export interface MaskRegion {
15
+ area: number;
16
+ bounds: CropBox;
17
+ }
18
+ export interface MaskEdgeReport {
19
+ /** Pixels at least half covered. */
20
+ area: number;
21
+ bounds: CropBox;
22
+ /** Pixels along the edge (inside, at least half covered, beside one less than half). */
23
+ edgeLength: number;
24
+ /**
25
+ * 0–1: how close the colour just inside the edge is to the colour just outside it, relative to
26
+ * the colour further in (0: the edge ring looks like the subject; 1: it looks like the
27
+ * background). Measured only where the inside and outside differ.
28
+ */
29
+ haloScore: number;
30
+ /** 0–1: the share of the edge within 2 px of a strong image edge. */
31
+ edgeAlignment: number;
32
+ /** Turning of the outline beyond what closing it needs, in radians per 100 px of outline (0: smooth). */
33
+ jaggedness: number;
34
+ /** 0–1: the share of edge pixels that are partly covered (0 < α < 1). */
35
+ softFraction: number;
36
+ /** Unselected areas enclosed by the selection, largest first (at most 10 listed). */
37
+ holes: {
38
+ count: number;
39
+ totalArea: number;
40
+ largest: MaskRegion[];
41
+ };
42
+ /** Selected pieces apart from the largest one, largest first (at most 10 listed). */
43
+ islands: {
44
+ count: number;
45
+ totalArea: number;
46
+ largest: MaskRegion[];
47
+ };
48
+ /** Up to 5 places to look at first (for `capture_view`), worst first. */
49
+ worst: Array<{
50
+ bounds: CropBox;
51
+ reason: string;
52
+ }>;
53
+ /** Plain-language findings with a suggested fix, empty when the edge looks clean. */
54
+ issues: string[];
55
+ }
56
+ /** Report thresholds (also in the masking skill). */
57
+ export declare const MASK_EDGE_THRESHOLDS: {
58
+ readonly halo: 0.35;
59
+ readonly alignment: 0.5;
60
+ readonly jaggedness: 15;
61
+ readonly soft: 0.9;
62
+ };
63
+ /**
64
+ * Inspects `mask`'s edge against `image` (RGBA, straight alpha, covering document pixels from
65
+ * `image.x`, `image.y`; outside it counts as transparent). Throws for an empty mask.
66
+ */
67
+ export declare function inspectMaskEdge(mask: SelectionMask, image: PixelBuffer & {
68
+ x: number;
69
+ y: number;
70
+ }, options?: InspectMaskEdgeOptions): MaskEdgeReport;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * A measured report on a mask's edge (`inspect_mask_edge`), so an agent can check a selection or
3
+ * a mask without looking at it: halo (old background left just inside the edge), how much of the
4
+ * edge sits on the image's own edges, how jagged the outline is, how soft it is, holes and stray
5
+ * islands, and the worst places to look at. Read-only; works in the mask's bounds.
6
+ */
7
+ import type { CropBox } from '../types.js';
8
+ import type { PixelBuffer, SelectionMask } from './mask.js';
9
+ export interface InspectMaskEdgeOptions {
10
+ /** Holes and islands smaller than this many pixels are left out (default 16). */
11
+ minArea?: number;
12
+ }
13
+ /** A hole or island: its area in pixels and bounds. */
14
+ export interface MaskRegion {
15
+ area: number;
16
+ bounds: CropBox;
17
+ }
18
+ export interface MaskEdgeReport {
19
+ /** Pixels at least half covered. */
20
+ area: number;
21
+ bounds: CropBox;
22
+ /** Pixels along the edge (inside, at least half covered, beside one less than half). */
23
+ edgeLength: number;
24
+ /**
25
+ * 0–1: how close the colour just inside the edge is to the colour just outside it, relative to
26
+ * the colour further in (0: the edge ring looks like the subject; 1: it looks like the
27
+ * background). Measured only where the inside and outside differ.
28
+ */
29
+ haloScore: number;
30
+ /** 0–1: the share of the edge within 2 px of a strong image edge. */
31
+ edgeAlignment: number;
32
+ /** Turning of the outline beyond what closing it needs, in radians per 100 px of outline (0: smooth). */
33
+ jaggedness: number;
34
+ /** 0–1: the share of edge pixels that are partly covered (0 < α < 1). */
35
+ softFraction: number;
36
+ /** Unselected areas enclosed by the selection, largest first (at most 10 listed). */
37
+ holes: {
38
+ count: number;
39
+ totalArea: number;
40
+ largest: MaskRegion[];
41
+ };
42
+ /** Selected pieces apart from the largest one, largest first (at most 10 listed). */
43
+ islands: {
44
+ count: number;
45
+ totalArea: number;
46
+ largest: MaskRegion[];
47
+ };
48
+ /** Up to 5 places to look at first (for `capture_view`), worst first. */
49
+ worst: Array<{
50
+ bounds: CropBox;
51
+ reason: string;
52
+ }>;
53
+ /** Plain-language findings with a suggested fix, empty when the edge looks clean. */
54
+ issues: string[];
55
+ }
56
+ /** Report thresholds (also in the masking skill). */
57
+ export declare const MASK_EDGE_THRESHOLDS: {
58
+ readonly halo: 0.35;
59
+ readonly alignment: 0.5;
60
+ readonly jaggedness: 15;
61
+ readonly soft: 0.9;
62
+ };
63
+ /**
64
+ * Inspects `mask`'s edge against `image` (RGBA, straight alpha, covering document pixels from
65
+ * `image.x`, `image.y`; outside it counts as transparent). Throws for an empty mask.
66
+ */
67
+ export declare function inspectMaskEdge(mask: SelectionMask, image: PixelBuffer & {
68
+ x: number;
69
+ y: number;
70
+ }, options?: InspectMaskEdgeOptions): MaskEdgeReport;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor",
3
- "version": "0.213.0",
3
+ "version": "0.214.0",
4
4
  "description": "UI-agnostic rich text and media editing core library",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -210,6 +210,7 @@ in the source frame at the document's bit depth, colour mode and profile. Read
210
210
  | `get_adjustments` | Read the current state: `values` by control id, `process` version (1 or 2), and `layers` bottom to top with id, kind, params, opacity, blend, enabled and mask. Call first, and to find layer ids. |
211
211
  | `list_controls` | Get every base control (id, label, section, min, max, step, default, `requiresProcess`), each layer kind's settable controls (plus `opacity`), the blend mode ids and the `layers.<layerId>.<controlId>` path format. Call once per session before writing. |
212
212
  | `get_selection` | Read the active selection: `empty`, `bounds` (natural pixels), `area` in pixels, `percent` of the image and a description. Check it after every select or modify step and before masking: a wand that covered 90% of the image is the wrong selection. |
213
+ | `inspect_mask_edge` | Measure an edge without looking: the selection (default) or a layer's `layer-mask` / `vector-mask` (`layerId`). Returns `haloScore`, `edgeAlignment`, `jaggedness`, `softFraction`, `holes`, `islands`, `worst` regions for `capture_view` and `issues` with fixes. Inspect, fix, inspect again (see `pixerate-image-selection-masking`). |
213
214
  | `list_channels` | Read the alpha channels (saved selections): id, name, bounds, percent, overlay and visibility, and whether Quick Mask mode is on. |
214
215
  | `select_subject` | Select › Subject. With a host segmentation model, `target` describes what to select ("the dog", "the sky") and the model's outlines are selected (`maxSegments` 1 for one). Without one, the subject that stands out most is found classically; `target` can't choose it (`method: "saliency"`, `note`). Combined by `mode`. Returns the selection, `found` (label, bounds) and `method`; nothing found leaves the selection unchanged. |
215
216
  | `list_layers` | Read the layer stack bottom to top as a tree: id, type (`pixel`, `adjustment`, `group`, `shape`, `annotation`, `smart`; smart objects add their `contents`, `smartFilters` and `filterMask`; shapes a `shape` summary of component ops and kinds and paint types, and `annotation` when migrated from one), name, document `bounds` of pixel layers, visibility, opacity, `fillOpacity`, blend, `clipped`, locks, a `mask` summary, an `effects` summary (master switch, scale, effect ids and kinds), pixel-layer `filters` (the Background's `develop` filter is the base adjustments), adjustment `kind` and `params`, group `children`, and which layer is `active`. Call it to understand a document with more than the Background before changing it; adjustment layer ids work with every adjustment-layer tool. |
@@ -44,10 +44,10 @@ This skill is the method. `pixerate-image-editor` has the full tool reference.
44
44
  what leaked, and `intersect` to limit it to a region (for example `select_rect` around the
45
45
  subject).
46
46
  **Check:** `bounds` hug the subject. A bounds as large as the image means a leak.
47
- 3. **Look at the edge.** Use `capture_view` with `region: "selection"` and `includeOverlays: true`,
48
- or `set_selection_display` `quickMask`, to see soft edges as a tint.
49
- **Check:** no holes in the subject, no islands in the background, and edges on the subject's
50
- outline.
47
+ 3. **Measure the edge, then look.** `inspect_mask_edge` scores it: `haloScore` ≥ 0.35 is old
48
+ background inside the edge, `edgeAlignment` < 0.5 is off the image's edges, `jaggedness` ≥ 15
49
+ zigzags; it counts `holes` and `islands`, `issues` names fixes, `worst` gives `capture_view` rects.
50
+ **Check:** `issues` is empty, or each one is intended (a deliberately soft edge or a second piece).
51
51
  4. **Clean it up.**
52
52
  - `modify_selection` `smooth` (2–4 px) removes wand speckle.
53
53
  - `grow_selection` (tolerance 10–30) picks up the shades a wand click missed;
@@ -89,7 +89,8 @@ This skill is the method. `pixerate-image-editor` has the full tool reference.
89
89
  writes the selection, a channel or a layer mask as a greyscale PNG; a matte that comes
90
90
  back goes into a channel with `load_channel_from_image` (or straight to the selection with
91
91
  `load_selection_from_image`).
92
- 7. **Verify.** `render_preview` at 1024 px or more, and `capture_view` on the edge at 2–8×.
92
+ 7. **Verify.** `inspect_mask_edge` again (`target: "layer-mask"` and `layerId` for a mask),
93
+ `render_preview` at 1024 px or more, and `capture_view` on `worst` regions at 2–8×.
93
94
  **Check:** no fringe of the old background colour, no stair-steps, no visible line where an
94
95
  adjustment ends. To judge a layer mask itself, `set_mask_view` `gray` (or `overlay`) and
95
96
  `capture_view` with `includeOverlays: true`; holes and stray grey show plainly there. Set it
@@ -220,8 +221,7 @@ This skill is the method. `pixerate-image-editor` has the full tool reference.
220
221
  - `select_layer_transparency`: a layer's own pixels
221
222
  - `grow_selection`, `select_similar`: add similar colour, connected or anywhere
222
223
  - `reselect`: undo a deselect
223
- - `save_selection`, `load_selection_from_channel`, `list_channels`: keep selections as alpha channels
224
- - `set_channel_properties`, `duplicate_channel`, `delete_channel`: manage channels
224
+ - `save_selection`, `load_selection_from_channel`, `list_channels`, `set_channel_properties`, `duplicate_channel`, `delete_channel`: keep and manage selections as alpha channels
225
225
  - `export_mask_image`: a selection, channel or layer mask as a greyscale PNG
226
226
  - `load_channel_from_image`: a mask image into a new channel
227
227
  - `set_quick_mask`: paint the selection
@@ -240,8 +240,8 @@ This skill is the method. `pixerate-image-editor` has the full tool reference.
240
240
  - `modify_selection`: expand, contract, feather, border, smooth
241
241
  - `refine_selection`: snap the edge to the image
242
242
  - `transform_selection`: move or scale the outline only
243
- - `capture_view`: inspect the edge at pixel level
244
- - `render_preview`: check the result
243
+ - `inspect_mask_edge`: measured halo, alignment, jaggedness, softness, holes and islands of an edge
244
+ - `capture_view`, `render_preview`: look at the edge at pixel level; check the result
245
245
  - `apply_selection_as_mask`: a masked adjustment layer in one step
246
246
  - `add_layer_mask`, `set_layer_mask_properties`, `apply_layer_mask`, `remove_layer_mask`: layer masks
247
247
  - `set_smart_filter_mask`: limit smart filters