@pixerate/editor 0.199.0 → 0.201.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.
- package/dist/image-editor/controller.d.cts +35 -0
- package/dist/image-editor/controller.d.ts +35 -0
- package/dist/image-editor/index.cjs +980 -667
- package/dist/image-editor/index.js +1238 -925
- package/dist/image-editor/selection/segment/focus.d.cts +22 -0
- package/dist/image-editor/selection/segment/focus.d.ts +22 -0
- package/dist/image-editor/selection/segment/guided.d.cts +13 -0
- package/dist/image-editor/selection/segment/guided.d.ts +13 -0
- package/dist/image-editor/selection/segment/index.d.cts +3 -0
- package/dist/image-editor/selection/segment/index.d.ts +3 -0
- package/dist/image-editor/selection/segment/sky.d.cts +21 -0
- package/dist/image-editor/selection/segment/sky.d.ts +21 -0
- package/dist/image-editor/selection/segment/work.d.cts +2 -2
- package/dist/image-editor/selection/segment/work.d.ts +2 -2
- package/dist/image-editor/selection/tool-options.d.cts +6 -0
- package/dist/image-editor/selection/tool-options.d.ts +6 -0
- package/package.json +1 -1
- package/skills/pixerate-image-editor/SKILL.md +2 -0
- package/skills/pixerate-image-selection-masking/SKILL.md +6 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Select › Focus Area: the parts of the image that are in focus. Fine detail survives only where
|
|
3
|
+
* the lens was focused, so a sharpness map (the Laplacian's local energy, less a floor for the
|
|
4
|
+
* image's noise) is split into in and out of focus, closed over smooth areas inside sharp ones,
|
|
5
|
+
* and fitted to the image's edges with a guided filter.
|
|
6
|
+
*/
|
|
7
|
+
import type { PixelBuffer, SelectionMask } from '../mask.cjs';
|
|
8
|
+
export interface FocusAreaOptions {
|
|
9
|
+
/** In-Focus Range 0..100 (default 50): higher takes in less sharp areas too. */
|
|
10
|
+
range?: number;
|
|
11
|
+
/** Image Noise Level 0..100 (default 0): raise it when grain is selected as detail. */
|
|
12
|
+
noise?: number;
|
|
13
|
+
/** Soften the edge over this many natural pixels (default 4; 0 for a hard edge). */
|
|
14
|
+
softness?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface FocusAreaResult {
|
|
17
|
+
selection: SelectionMask;
|
|
18
|
+
/** The noise measured in the image (σ of luminance, in levels of 255). */
|
|
19
|
+
noiseLevel: number;
|
|
20
|
+
}
|
|
21
|
+
/** The in-focus areas of `pixels` as a selection of the whole image. */
|
|
22
|
+
export declare function focusArea(pixels: PixelBuffer, options?: FocusAreaOptions): FocusAreaResult;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Select › Focus Area: the parts of the image that are in focus. Fine detail survives only where
|
|
3
|
+
* the lens was focused, so a sharpness map (the Laplacian's local energy, less a floor for the
|
|
4
|
+
* image's noise) is split into in and out of focus, closed over smooth areas inside sharp ones,
|
|
5
|
+
* and fitted to the image's edges with a guided filter.
|
|
6
|
+
*/
|
|
7
|
+
import type { PixelBuffer, SelectionMask } from '../mask.js';
|
|
8
|
+
export interface FocusAreaOptions {
|
|
9
|
+
/** In-Focus Range 0..100 (default 50): higher takes in less sharp areas too. */
|
|
10
|
+
range?: number;
|
|
11
|
+
/** Image Noise Level 0..100 (default 0): raise it when grain is selected as detail. */
|
|
12
|
+
noise?: number;
|
|
13
|
+
/** Soften the edge over this many natural pixels (default 4; 0 for a hard edge). */
|
|
14
|
+
softness?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface FocusAreaResult {
|
|
17
|
+
selection: SelectionMask;
|
|
18
|
+
/** The noise measured in the image (σ of luminance, in levels of 255). */
|
|
19
|
+
noiseLevel: number;
|
|
20
|
+
}
|
|
21
|
+
/** The in-focus areas of `pixels` as a selection of the whole image. */
|
|
22
|
+
export declare function focusArea(pixels: PixelBuffer, options?: FocusAreaOptions): FocusAreaResult;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for the masks Focus Area and Select Sky compute on the reduced copy: its luminance and
|
|
3
|
+
* colour planes (the guide for `guidedFilterColor`, which fits a rough mask to the image's edges)
|
|
4
|
+
* and scaling a soft mask back up to the image.
|
|
5
|
+
*/
|
|
6
|
+
import { type SelectionMask } from '../mask.cjs';
|
|
7
|
+
import type { WorkImage } from './work.cjs';
|
|
8
|
+
/** The work image as three planes of 0..1 values, the guide `guidedFilterColor` takes. */
|
|
9
|
+
export declare function workPlanes(work: WorkImage): [Float32Array, Float32Array, Float32Array];
|
|
10
|
+
/** The work image's luminance, 0..1. */
|
|
11
|
+
export declare function workLuma(work: WorkImage): Float32Array;
|
|
12
|
+
/** A soft mask over the whole work image (0..1), scaled up bilinearly to a selection of the image. */
|
|
13
|
+
export declare function softMaskToSelection(work: WorkImage, mask: Float32Array): SelectionMask;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for the masks Focus Area and Select Sky compute on the reduced copy: its luminance and
|
|
3
|
+
* colour planes (the guide for `guidedFilterColor`, which fits a rough mask to the image's edges)
|
|
4
|
+
* and scaling a soft mask back up to the image.
|
|
5
|
+
*/
|
|
6
|
+
import { type SelectionMask } from '../mask.js';
|
|
7
|
+
import type { WorkImage } from './work.js';
|
|
8
|
+
/** The work image as three planes of 0..1 values, the guide `guidedFilterColor` takes. */
|
|
9
|
+
export declare function workPlanes(work: WorkImage): [Float32Array, Float32Array, Float32Array];
|
|
10
|
+
/** The work image's luminance, 0..1. */
|
|
11
|
+
export declare function workLuma(work: WorkImage): Float32Array;
|
|
12
|
+
/** A soft mask over the whole work image (0..1), scaled up bilinearly to a selection of the image. */
|
|
13
|
+
export declare function softMaskToSelection(work: WorkImage, mask: Float32Array): SelectionMask;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Select › Sky without a segmentation model. Sky is smooth, sits at the top of the frame, and is
|
|
3
|
+
* blue, or bright and grey when overcast. Each pixel gets a score from those three cues; the sky
|
|
4
|
+
* is grown down from the top rows through high-scoring pixels; patches of the same colour seen
|
|
5
|
+
* through gaps (between branches, under a bridge) are added; and the edge is fitted to the image
|
|
6
|
+
* with the colour guided filter.
|
|
7
|
+
*/
|
|
8
|
+
import { type PixelBuffer, type SelectionMask } from '../mask.cjs';
|
|
9
|
+
export interface SkyOptions {
|
|
10
|
+
/** 0..100 (default 50): higher takes in less sky-like pixels (haze, a sunset glow). */
|
|
11
|
+
threshold?: number;
|
|
12
|
+
/** Soften the edge over this many natural pixels (default 4; 0 for a hard edge). */
|
|
13
|
+
softness?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface FoundSky {
|
|
16
|
+
selection: SelectionMask;
|
|
17
|
+
/** Why nothing was selected, when nothing was. */
|
|
18
|
+
reason?: string;
|
|
19
|
+
}
|
|
20
|
+
/** The sky in `pixels`, as a selection of the whole image (empty, with a reason, when there is none). */
|
|
21
|
+
export declare function findSky(pixels: PixelBuffer, options?: SkyOptions): FoundSky;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Select › Sky without a segmentation model. Sky is smooth, sits at the top of the frame, and is
|
|
3
|
+
* blue, or bright and grey when overcast. Each pixel gets a score from those three cues; the sky
|
|
4
|
+
* is grown down from the top rows through high-scoring pixels; patches of the same colour seen
|
|
5
|
+
* through gaps (between branches, under a bridge) are added; and the edge is fitted to the image
|
|
6
|
+
* with the colour guided filter.
|
|
7
|
+
*/
|
|
8
|
+
import { type PixelBuffer, type SelectionMask } from '../mask.js';
|
|
9
|
+
export interface SkyOptions {
|
|
10
|
+
/** 0..100 (default 50): higher takes in less sky-like pixels (haze, a sunset glow). */
|
|
11
|
+
threshold?: number;
|
|
12
|
+
/** Soften the edge over this many natural pixels (default 4; 0 for a hard edge). */
|
|
13
|
+
softness?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface FoundSky {
|
|
16
|
+
selection: SelectionMask;
|
|
17
|
+
/** Why nothing was selected, when nothing was. */
|
|
18
|
+
reason?: string;
|
|
19
|
+
}
|
|
20
|
+
/** The sky in `pixels`, as a selection of the whole image (empty, with a reason, when there is none). */
|
|
21
|
+
export declare function findSky(pixels: PixelBuffer, options?: SkyOptions): FoundSky;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The reduced copy of the image the
|
|
3
|
-
* on, and scaling their result back up to the image
|
|
2
|
+
* The reduced copy of the image the segmentations (Quick, Object and Subject Selection, Focus
|
|
3
|
+
* Area) work on, and scaling their result back up to the image.
|
|
4
4
|
*/
|
|
5
5
|
import { type PixelBuffer, type SelectionMask } from '../mask.cjs';
|
|
6
6
|
/** The reduced image the segmentations work on (sRGB, 0..255 per channel). */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The reduced copy of the image the
|
|
3
|
-
* on, and scaling their result back up to the image
|
|
2
|
+
* The reduced copy of the image the segmentations (Quick, Object and Subject Selection, Focus
|
|
3
|
+
* Area) work on, and scaling their result back up to the image.
|
|
4
4
|
*/
|
|
5
5
|
import { type PixelBuffer, type SelectionMask } from '../mask.js';
|
|
6
6
|
/** The reduced image the segmentations work on (sRGB, 0..255 per channel). */
|
|
@@ -47,6 +47,12 @@ export interface SelectionToolOptions {
|
|
|
47
47
|
objectSampleAll?: boolean;
|
|
48
48
|
/** Object Selection: smoother, less blocky edges (Auto-Enhance; default false). */
|
|
49
49
|
objectEnhance?: boolean;
|
|
50
|
+
/** Focus Area: In-Focus Range 0..100 (default 50). */
|
|
51
|
+
focusRange?: number;
|
|
52
|
+
/** Focus Area: Image Noise Level 0..100 (default 0). */
|
|
53
|
+
focusNoise?: number;
|
|
54
|
+
/** Focus Area: soften the edge over this many pixels (default 4). */
|
|
55
|
+
focusSoftness?: number;
|
|
50
56
|
/** Type Mask: the text to select (default "Type"). A click places its first baseline. */
|
|
51
57
|
typeText?: string;
|
|
52
58
|
/** Type Mask: font size in px (default 72). */
|
|
@@ -47,6 +47,12 @@ export interface SelectionToolOptions {
|
|
|
47
47
|
objectSampleAll?: boolean;
|
|
48
48
|
/** Object Selection: smoother, less blocky edges (Auto-Enhance; default false). */
|
|
49
49
|
objectEnhance?: boolean;
|
|
50
|
+
/** Focus Area: In-Focus Range 0..100 (default 50). */
|
|
51
|
+
focusRange?: number;
|
|
52
|
+
/** Focus Area: Image Noise Level 0..100 (default 0). */
|
|
53
|
+
focusNoise?: number;
|
|
54
|
+
/** Focus Area: soften the edge over this many pixels (default 4). */
|
|
55
|
+
focusSoftness?: number;
|
|
50
56
|
/** Type Mask: the text to select (default "Type"). A click places its first baseline. */
|
|
51
57
|
typeText?: string;
|
|
52
58
|
/** Type Mask: font size in px (default 72). */
|
package/package.json
CHANGED
|
@@ -254,6 +254,8 @@ in the source frame at the document's bit depth, colour mode and profile. Read
|
|
|
254
254
|
| `select_line` | Single row or column marquee: `orientation` `row` (at y) or `column` (at x), `position` in natural px, `mode`. A 1 px line across the image. Returns the summary. |
|
|
255
255
|
| `quick_select` | Quick Selection: `strokes` (brush paths of `{x, y}`), `size` (diameter, default 30), `mode`, `sampleAllLayers`, `enhanceEdge`. Each stroke grows out to its region's edges; with `replace` the first replaces and the rest add. Paint inside the area, then check and fix with `add` / `subtract` strokes. Returns the summary. |
|
|
256
256
|
| `select_object` | Object Selection (GrabCut): `rect` (a box around the object) or `point` (on it), `mode`, `sampleAllLayers`, `enhanceEdge`. Outside the box is background. Make the box a little larger than the object. Returns the summary. |
|
|
257
|
+
| `select_focus_area` | Select › Focus Area: the in-focus (sharp) parts, edge fitted to the image. `range` 0..100 (higher takes in softer areas), `noise` 0..100 (raise when grain is selected), `softness` px, `mode`. Returns the summary and `noiseLevel`. |
|
|
258
|
+
| `select_sky` | Select › Sky: the sky (blue or overcast, from the top down, with patches through gaps), edge fitted to the skyline. `threshold` 0..100 (higher takes in haze), `softness` px, `mode`. Returns the summary, and `note` when none was found. |
|
|
257
259
|
| `select_polygon` | The lasso: `points` (at least 3 `{x, y}` along the outline, closed automatically), `mode`, `feather`, `antiAlias`; `snapToEdges: {width, contrast}` makes it the Magnetic Lasso (points snap to edges, the outline follows them). Trace a subject's contour, not its box. Returns the summary (plus `outlinePoints` when snapped). |
|
|
258
260
|
| `magic_wand` | Select similar colour from `x`, `y`: `tolerance` 0..255 (default 32), `contiguous` (default true), `distance` `rgb` or `perceptual`, `sampleMerged`, `sample` (`composite` or `active-layer`), `mode`, `feather`. For flat backdrops and solid colours. Returns the summary. |
|
|
259
261
|
| `select_color_range` | Color Range, soft: `samples` (`[{color, x?, y?}]`) or a `preset` (reds … magentas, highlights, midtones, shadows, skinTones); `fuzziness` (samples 0..200, default 40; tone presets' falloff, default 20), `localized` px radius around positioned samples, `invert`, `sample`, `mode`, `feather`. Returns the summary. |
|
|
@@ -99,6 +99,8 @@ This skill is the method. `pixerate-image-editor` has the full tool reference.
|
|
|
99
99
|
| One object among others, where you can box it (a product on a table, a person in a group) | `select_object` with a `rect` a little larger than the object on every side; then `quick_select` add / subtract strokes for what it missed |
|
|
100
100
|
| A subject with a clear outline (product, person, animal) | `select_subject` (with a host model, by description; without one it takes whatever stands out most, so check `method` and the result); else `select_object` around it, or `select_polygon` with `snapToEdges` (12–30 points within `width` of the edge), then `refine_selection` |
|
|
101
101
|
| An area or subject that differs from its surroundings (a shirt, a sky, a car) | `quick_select` with strokes painted inside it, away from the edge (`size` a fraction of its width); `add` / `subtract` strokes where it fell short or leaked |
|
|
102
|
+
| The sky (to replace, recolour, or to leave out with `invert_selection`) | `select_sky`; raise `threshold` for haze or a sunset glow, lower it if pale buildings come in |
|
|
103
|
+
| A sharp subject on a blurred background (shallow depth of field) | `select_focus_area`; raise `range` if parts of the subject are missing, `noise` if grainy background comes in |
|
|
102
104
|
| A low-contrast or busy outline the edges don't follow | `select_polygon` without `snapToEdges`, along the contour (20–60 points) |
|
|
103
105
|
| Flat backdrop or solid colour (studio white, green screen, sky without clouds) | `magic_wand` on the backdrop (`tolerance` 20–40; `distance: "perceptual"` for gradients), then `invert_selection` |
|
|
104
106
|
| A colour spread across the image (all the reds, a dress) | `select_color_range` with `samples` (several picks) or a hue `preset`; `localized` to keep one area |
|
|
@@ -117,8 +119,8 @@ This skill is the method. `pixerate-image-editor` has the full tool reference.
|
|
|
117
119
|
Add the new background with `add_pixel_layer` and move it under the cutout (`move_layer`).
|
|
118
120
|
`render_preview` and look for a halo; if there is one, load the copy's pixels back as a
|
|
119
121
|
selection, `shrink` 1 px, and mask.
|
|
120
|
-
- **Replace the sky:** `
|
|
121
|
-
`add` missed patches, `refine_selection` radius 8–16 along the horizon and trees, then
|
|
122
|
+
- **Replace the sky:** `select_sky` (or `magic_wand` / `select_color_range` `preset: "blues"`
|
|
123
|
+
if it finds none), `add` missed patches, `refine_selection` radius 8–16 along the horizon and trees, then
|
|
122
124
|
`add_layer_mask` on the new sky layer. Match it with a clipped curves layer (`clipped: true`).
|
|
123
125
|
- **Adjust only part of an image:** select, then `apply_selection_as_mask` with `kind` and
|
|
124
126
|
`params`, and `feather` in proportion to the image (a few px for objects, 50–200 px for
|
|
@@ -203,6 +205,8 @@ This skill is the method. `pixerate-image-editor` has the full tool reference.
|
|
|
203
205
|
- `select_polygon`: the lasso, along a contour; with `snapToEdges`, the Magnetic Lasso
|
|
204
206
|
- `quick_select`: brush strokes that grow out to the region's edges
|
|
205
207
|
- `select_object`: the object in a box or under a point
|
|
208
|
+
- `select_focus_area`: what is in focus
|
|
209
|
+
- `select_sky`: the sky
|
|
206
210
|
- `select_line`: a single row or column
|
|
207
211
|
- `select_layer_transparency`: a layer's own pixels
|
|
208
212
|
- `grow_selection`, `select_similar`: add similar colour, connected or anywhere
|