@pixerate/editor 0.181.0 → 0.183.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.
Files changed (42) hide show
  1. package/dist/agent/index.cjs +5 -5
  2. package/dist/agent/index.js +3 -3
  3. package/dist/animation/index.cjs +2 -2
  4. package/dist/animation/index.js +1 -1
  5. package/dist/chart/index.cjs +7 -7
  6. package/dist/chart/index.js +1 -1
  7. package/dist/{chunk-5EMS4BZG.cjs → chunk-3SLBXKAW.cjs} +15 -7
  8. package/dist/{chunk-WL4IN36A.js → chunk-EHTX34RE.js} +13 -5
  9. package/dist/{chunk-ZXTO6U7T.js → chunk-GI3AVES4.js} +1 -1
  10. package/dist/{chunk-O2ANJFUF.js → chunk-IVSWRVB4.js} +8 -1
  11. package/dist/{chunk-SWTUM32H.cjs → chunk-K7ENM55P.cjs} +8 -1
  12. package/dist/{chunk-NJGFSOPP.cjs → chunk-U4QN36YT.cjs} +2 -2
  13. package/dist/commands/index.cjs +3 -3
  14. package/dist/commands/index.js +2 -2
  15. package/dist/diagram/index.cjs +7 -7
  16. package/dist/diagram/index.js +1 -1
  17. package/dist/image-editor/controller.d.cts +2 -0
  18. package/dist/image-editor/controller.d.ts +2 -0
  19. package/dist/image-editor/index.cjs +135 -115
  20. package/dist/image-editor/index.js +28 -8
  21. package/dist/image-editor/playback.d.cts +14 -4
  22. package/dist/image-editor/playback.d.ts +14 -4
  23. package/dist/image-editor/selection/segmentation.d.cts +3 -0
  24. package/dist/image-editor/selection/segmentation.d.ts +3 -0
  25. package/dist/paint-editor/index.cjs +6 -6
  26. package/dist/paint-editor/index.js +1 -1
  27. package/dist/tools/index.cjs +4 -4
  28. package/dist/tools/index.js +3 -3
  29. package/dist/tools/playback.d.cts +4 -1
  30. package/dist/tools/playback.d.ts +4 -1
  31. package/dist/tools/presence.d.cts +15 -3
  32. package/dist/tools/presence.d.ts +15 -3
  33. package/dist/tools/registry.d.cts +7 -1
  34. package/dist/tools/registry.d.ts +7 -1
  35. package/dist/vector/controller.d.cts +13 -0
  36. package/dist/vector/controller.d.ts +13 -0
  37. package/dist/vector/index.cjs +20 -1
  38. package/dist/vector/index.js +19 -0
  39. package/package.json +1 -1
  40. package/skills/README.md +7 -0
  41. package/skills/pixerate-image-editor/SKILL.md +29 -29
  42. package/skills/pixerate-image-selection-masking/SKILL.md +172 -0
@@ -0,0 +1,172 @@
1
+ ---
2
+ name: pixerate-image-selection-masking
3
+ description: The selection and masking workflow in the Pixerate image editor - cutting out a subject, removing or replacing a background, selecting hair, fur or sky, limiting an adjustment, filter or paint to part of an image, and making, feathering, refining, inverting, loading or checking masks. Use when asked to cut out, isolate, extract or mask something, replace a sky or background, adjust or sharpen only part of a photo, make a vignette, or when select_rect, magic_wand, select_color_range, select_subject, refine_selection or add_layer_mask are available. Load with pixerate-image-editor, which lists every tool.
4
+ metadata:
5
+ kind: workflow
6
+ reference: pixerate-image-editor
7
+ ---
8
+
9
+ # Selection and masking
10
+
11
+ A selection is an 8-bit soft mask over the source image (0 = not selected, 255 = selected,
12
+ values between are partly selected). It limits painting, fills, Layer via Copy and Free
13
+ Transform, and becomes a layer mask with `apply_selection_as_mask` or `add_layer_mask`.
14
+ Coordinates are natural pixels of the source image, before crop, rotation and flips. Read
15
+ `get_selection` bounds or `get_image_info`, never screen pixels.
16
+
17
+ This skill is the method. `pixerate-image-editor` has the full tool reference.
18
+
19
+ ## Goal and quality bar
20
+
21
+ - The selection covers the subject and nothing else. `percent` and `bounds` agree with what you
22
+ expect before you mask anything.
23
+ - Edges match the subject: hard objects stay crisp (anti-aliased, 0–2 px feather), while hair,
24
+ fur, foliage and glass have soft, refined edges.
25
+ - There is no halo of the old background around a cutout, and no hard line where a local
26
+ adjustment stops.
27
+ - The result stays editable. Use masks rather than deleted pixels, and mask feather and density
28
+ rather than a baked blur. Bake only when the user asks.
29
+
30
+ ## Inputs to confirm
31
+
32
+ - **What** to select, in words, and **what for**: a cutout (layer), a local adjustment, a
33
+ background swap, or a filter on part of the image.
34
+ - **Which layer** to act on (`list_layers`, `set_active_layer`).
35
+ - **Hard or soft edge** when it is not obvious (a product shot, or a portrait with loose hair).
36
+
37
+ ## Working method
38
+
39
+ 1. **Choose the method by subject** (see the decision table).
40
+ **Check:** `get_selection` → `empty: false` and a plausible `percent` (for a person in a
41
+ portrait, typically 15–50 %). A wand or range above about 80 % has flooded: undo, then lower
42
+ `tolerance` / `fuzziness`.
43
+ 2. **Build it in steps** with `mode`: start with `replace`, `add` what was missed, `subtract`
44
+ what leaked, and `intersect` to limit it to a region (for example `select_rect` around the
45
+ subject).
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.
51
+ 4. **Clean it up.**
52
+ - `modify_selection` `smooth` (2–4 px) removes wand speckle.
53
+ - `grow_selection` (tolerance 10–30) picks up the shades a wand click missed;
54
+ `select_similar` adds the same colours elsewhere in the image.
55
+ - `contract` 1–2 px pulls the edge off a halo.
56
+ - `refine_selection` snaps to real edges: radius 2–4 for hard edges, 8–20 for hair and fur;
57
+ `smartRadius: true` for mixed edges.
58
+ - `shiftEdge` −10..−30 % tightens a refined edge that picked up background.
59
+ **Check:** `percent` changed by roughly what you intended (a few percent at most for a
60
+ cleanup).
61
+ 5. **Output.** Choose by goal:
62
+ - A local adjustment: `apply_selection_as_mask` with `kind` (one step).
63
+ - A cutout: `layer_via_copy` (the original stays), or `add_layer_mask` `from: "selection"` on
64
+ the layer itself.
65
+ - Painting or fills inside it: keep the selection active and paint.
66
+ Soften with the mask's own `feather` / `density` rather than `modify_selection` `feather`, so
67
+ it stays adjustable.
68
+ 6. **Verify.** `render_preview` at 1024 px or more, and `capture_view` on the edge at 2–8×.
69
+ **Check:** no fringe of the old background colour, no stair-steps, no visible line where an
70
+ adjustment ends. Fix by loading the mask back (`load_selection_from_mask`), refining, and
71
+ masking again.
72
+
73
+ ## Decision table
74
+
75
+ | Subject | Method |
76
+ | --- | --- |
77
+ | Geometric areas: a frame, a screen, a band | `select_rect` / `select_ellipse`, with `feather` for soft transitions |
78
+ | A subject with a clear outline (product, person, animal) | `select_subject` if the host has a model; else `select_polygon` along the contour (20–60 points), then `refine_selection` |
79
+ | 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` |
80
+ | 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 |
81
+ | Tones (shadows, highlights, a luminosity mask) | `select_color_range` with `preset` `shadows` / `midtones` / `highlights` |
82
+ | Skin for retouching | `select_color_range` `preset: "skinTones"`, then `intersect` with a box around the face |
83
+ | An AI matte or saved mask from the host | `load_selection_from_image` (soft: no `threshold`), then `refine_selection` |
84
+ | An existing layer mask | `load_selection_from_mask` |
85
+ | A cutout, shape or text already on its own layer | `select_layer_transparency` (exact, soft where the layer is) |
86
+ | A dead pixel row or column | `select_line`, then fill or heal it |
87
+
88
+ ## Recipes
89
+
90
+ - **Cut out a subject onto a new background:** select (table), refine, then `layer_via_copy`.
91
+ Add the new background with `add_pixel_layer` and move it under the cutout (`move_layer`).
92
+ `render_preview` and look for a halo; if there is one, load the copy's pixels back as a
93
+ selection, `shrink` 1 px, and mask.
94
+ - **Replace the sky:** `magic_wand` or `select_color_range` `preset: "blues"` on the sky,
95
+ `add` missed patches, `refine_selection` radius 8–16 along the horizon and trees, then
96
+ `add_layer_mask` on the new sky layer. Match it with a clipped curves layer (`clipped: true`).
97
+ - **Adjust only part of an image:** select, then `apply_selection_as_mask` with `kind` and
98
+ `params`, and `feather` in proportion to the image (a few px for objects, 50–200 px for
99
+ broad light).
100
+ - **Vignette:** `select_ellipse` inset 5–10 % from the edges, `invert_selection`, then
101
+ `apply_selection_as_mask` `kind: "curves"` (darken), with the mask `feather` at 15–25 % of
102
+ the short side.
103
+ - **Graduated filter:** `select_rect` over the top third with a large `feather`, then a curves or
104
+ hue/saturation layer through the mask.
105
+ - **Hide part of a layer:** `add_layer_mask` (`hide-selection` hides what is selected), or paint
106
+ black on the mask with `paint_stroke` `channel: "mask"` and a soft brush (`hardness`
107
+ 0..0.3); paint white to bring it back. Never erase.
108
+ - **Edit a cutout's edge:** `add_layer_mask` `from: "transparency"` moves the layer's alpha into
109
+ a mask you can refine and repaint.
110
+ - **Dodge and burn through masks:** an adjustment layer with a `hide-all` mask
111
+ (`add_layer_mask`), then paint white on it with `paint_stroke` `channel: "mask"`, at low
112
+ opacity.
113
+ - **Selective sharpening or blur:** select, then `set_smart_filter_mask` `from: "selection"` on
114
+ a smart object's filters.
115
+ - **Clip a texture or colour to a layer:** put it directly above and set `clipped: true` with
116
+ `set_layer_properties`; no selection is needed.
117
+ - **Picture inside a frame:** mask the picture with the frame's shape, then
118
+ `set_layer_mask_properties` `linked: false` so the picture moves under a fixed mask; link it
119
+ again afterwards.
120
+
121
+ ## Pitfalls
122
+
123
+ - **Flooding:** a wand or range that covers most of the image. Start low (wand 20–40, range
124
+ 30–60), check `percent`, and grow with `mode: "add"`.
125
+ - **Box instead of outline:** `select_rect` around a subject masks its background too. Trace
126
+ the contour.
127
+ - **Over-feathering hard objects:** a 10 px feather on a product looks like a glow. Keep hard
128
+ edges at 0–2 px and refine soft ones instead.
129
+ - **Halo:** the old background shows as a light or dark fringe. `contract` 1–2 px or
130
+ `shiftEdge` negative before masking.
131
+ - **Baking too early:** `apply_layer_mask`, `merge_down` and `layer_via_copy` with `cut: true`
132
+ are hard to revise. Keep masks until the user is happy.
133
+ - **Expand is not Grow:** `modify_selection` `expand` moves the edge by distance;
134
+ `grow_selection` adds similar colour. Use the one that matches the problem.
135
+ - **Deselected by mistake:** `reselect` brings it back (or `undo_image`).
136
+ - **Empty selection:** `modify_selection`, `refine_selection` and `apply_selection_as_mask` fail
137
+ on it. Select first.
138
+ - **Hidden selection still applies:** with `set_selection_display` `none`, paint and fills are
139
+ still limited to it. `deselect` before a whole-layer edit.
140
+ - **Wrong coordinates:** use natural image pixels, not preview pixels. On a cropped or rotated
141
+ image, a rectangle measured in the preview lands in the wrong place.
142
+ - **Deprecated tools:** `select_region` and `select_by_color` still work, but use the tools
143
+ below.
144
+
145
+ ## Tools used
146
+
147
+ - `get_selection`: empty, bounds, area and percent after every step
148
+ - `select_all`, `deselect`, `invert_selection`: whole-image selections
149
+ - `select_rect`, `select_ellipse`: marquees
150
+ - `select_polygon`: the lasso, along a contour
151
+ - `select_line`: a single row or column
152
+ - `select_layer_transparency`: a layer's own pixels
153
+ - `grow_selection`, `select_similar`: add similar colour, connected or anywhere
154
+ - `reselect`: undo a deselect
155
+ - `magic_wand`: similar colour from a seed
156
+ - `select_color_range`: colour samples, hue, tone and skin presets
157
+ - `select_subject`: a subject by description (needs a host model)
158
+ - `load_selection_from_image`: AI or saved mattes
159
+ - `load_selection_from_mask`: a layer mask back to a selection
160
+ - `set_selection_display`: ants, Quick Mask tint or hidden
161
+ - `modify_selection`: expand, contract, feather, border, smooth
162
+ - `refine_selection`: snap the edge to the image
163
+ - `transform_selection`: move or scale the outline only
164
+ - `capture_view`: inspect the edge at pixel level
165
+ - `render_preview`: check the result
166
+ - `apply_selection_as_mask`: a masked adjustment layer in one step
167
+ - `add_layer_mask`, `set_layer_mask_properties`, `apply_layer_mask`, `remove_layer_mask`: layer masks
168
+ - `set_smart_filter_mask`: limit smart filters
169
+ - `layer_via_copy`: lift the selection onto a new layer
170
+ - `paint_stroke`: paint on a mask with `channel: "mask"`
171
+ - `undo_image`: take back a step
172
+ - `set_layer_properties`: clipping