@pixerate/editor 0.182.0 → 0.185.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 (37) hide show
  1. package/dist/{chunk-UHMSMUHK.cjs → chunk-C6TRAAG4.cjs} +3 -1
  2. package/dist/{chunk-Y46OMERN.js → chunk-GYYSPMVU.js} +3 -1
  3. package/dist/image-editor/controller.d.cts +152 -8
  4. package/dist/image-editor/controller.d.ts +152 -8
  5. package/dist/image-editor/index.cjs +1986 -832
  6. package/dist/image-editor/index.js +1209 -55
  7. package/dist/image-editor/layers/panel.d.cts +23 -1
  8. package/dist/image-editor/layers/panel.d.ts +23 -1
  9. package/dist/image-editor/selection/gesture.d.cts +40 -2
  10. package/dist/image-editor/selection/gesture.d.ts +40 -2
  11. package/dist/image-editor/selection/index.d.cts +1 -0
  12. package/dist/image-editor/selection/index.d.ts +1 -0
  13. package/dist/image-editor/selection/modify.d.cts +3 -2
  14. package/dist/image-editor/selection/modify.d.ts +3 -2
  15. package/dist/image-editor/selection/stroke.d.cts +8 -0
  16. package/dist/image-editor/selection/stroke.d.ts +8 -0
  17. package/dist/image-editor/selection/tool-options.d.cts +12 -2
  18. package/dist/image-editor/selection/tool-options.d.ts +12 -2
  19. package/dist/image-editor/selection/wand.d.cts +37 -0
  20. package/dist/image-editor/selection/wand.d.ts +37 -0
  21. package/dist/image-editor/selection-tools.d.cts +8 -3
  22. package/dist/image-editor/selection-tools.d.ts +8 -3
  23. package/dist/image-editor/tools.d.cts +8 -2
  24. package/dist/image-editor/tools.d.ts +8 -2
  25. package/dist/image-editor/types.d.cts +2 -0
  26. package/dist/image-editor/types.d.ts +2 -0
  27. package/dist/paint-editor/index.cjs +6 -6
  28. package/dist/paint-editor/index.js +1 -1
  29. package/dist/vector/controller.d.cts +13 -0
  30. package/dist/vector/controller.d.ts +13 -0
  31. package/dist/vector/index.cjs +20 -1
  32. package/dist/vector/index.js +19 -0
  33. package/package.json +1 -1
  34. package/skills/README.md +7 -0
  35. package/skills/pixerate-image-editor/SKILL.md +41 -50
  36. package/skills/pixerate-image-editor/references/free-transform.md +22 -0
  37. package/skills/pixerate-image-selection-masking/SKILL.md +193 -0
@@ -0,0 +1,193 @@
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: `add_adjustment_layer` while the selection is active (it is masked
63
+ by it), or `apply_selection_as_mask` with `kind`. Filters (`apply_effect`,
64
+ `add_smart_filter`) are also limited to an active selection.
65
+ - A cutout: `layer_via_copy` (the original stays), or `add_layer_mask` `from: "selection"` on
66
+ the layer itself.
67
+ - Painting or fills inside it: keep the selection active and paint; `stroke_selection` for
68
+ an outline that follows it.
69
+ - Removing what it covers: `content_aware_fill` `output: "new-layer"`.
70
+ - A copy elsewhere: `copy_pixels`, then `paste_pixels` (`into` masks it by a selection).
71
+ Soften with the mask's own `feather` / `density` rather than `modify_selection` `feather`, so
72
+ it stays adjustable.
73
+ 6. **Verify.** `render_preview` at 1024 px or more, and `capture_view` on the edge at 2–8×.
74
+ **Check:** no fringe of the old background colour, no stair-steps, no visible line where an
75
+ adjustment ends. Fix by loading the mask back (`load_selection_from_mask`), refining, and
76
+ masking again.
77
+
78
+ ## Decision table
79
+
80
+ | Subject | Method |
81
+ | --- | --- |
82
+ | Geometric areas: a frame, a screen, a band | `select_rect` / `select_ellipse`, with `feather` for soft transitions |
83
+ | 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` |
84
+ | 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` |
85
+ | 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 |
86
+ | Tones (shadows, highlights, a luminosity mask) | `select_color_range` with `preset` `shadows` / `midtones` / `highlights` |
87
+ | Skin for retouching | `select_color_range` `preset: "skinTones"`, then `intersect` with a box around the face |
88
+ | An AI matte or saved mask from the host | `load_selection_from_image` (soft: no `threshold`), then `refine_selection` |
89
+ | An existing layer mask | `load_selection_from_mask` |
90
+ | A cutout, shape or text already on its own layer | `select_layer_transparency` (exact, soft where the layer is) |
91
+ | A dead pixel row or column | `select_line`, then fill or heal it |
92
+
93
+ ## Recipes
94
+
95
+ - **Cut out a subject onto a new background:** select (table), refine, then `layer_via_copy`.
96
+ Add the new background with `add_pixel_layer` and move it under the cutout (`move_layer`).
97
+ `render_preview` and look for a halo; if there is one, load the copy's pixels back as a
98
+ selection, `shrink` 1 px, and mask.
99
+ - **Replace the sky:** `magic_wand` or `select_color_range` `preset: "blues"` on the sky,
100
+ `add` missed patches, `refine_selection` radius 8–16 along the horizon and trees, then
101
+ `add_layer_mask` on the new sky layer. Match it with a clipped curves layer (`clipped: true`).
102
+ - **Adjust only part of an image:** select, then `apply_selection_as_mask` with `kind` and
103
+ `params`, and `feather` in proportion to the image (a few px for objects, 50–200 px for
104
+ broad light).
105
+ - **Vignette:** `select_ellipse` inset 5–10 % from the edges, `invert_selection`, then
106
+ `apply_selection_as_mask` `kind: "curves"` (darken), with the mask `feather` at 15–25 % of
107
+ the short side.
108
+ - **Graduated filter:** `select_rect` over the top third with a large `feather`, then a curves or
109
+ hue/saturation layer through the mask.
110
+ - **Hide part of a layer:** `add_layer_mask` (`hide-selection` hides what is selected), or paint
111
+ black on the mask with `paint_stroke` `channel: "mask"` and a soft brush (`hardness`
112
+ 0..0.3); paint white to bring it back. Never erase.
113
+ - **Edit a cutout's edge:** `add_layer_mask` `from: "transparency"` moves the layer's alpha into
114
+ a mask you can refine and repaint.
115
+ - **Dodge and burn through masks:** an adjustment layer with a `hide-all` mask
116
+ (`add_layer_mask`), then paint white on it with `paint_stroke` `channel: "mask"`, at low
117
+ opacity.
118
+ - **Selective sharpening or blur:** select, then `set_smart_filter_mask` `from: "selection"` on
119
+ a smart object's filters.
120
+ - **Clip a texture or colour to a layer:** put it directly above and set `clipped: true` with
121
+ `set_layer_properties`; no selection is needed.
122
+ - **Remove an object:** select it with a 2–4 px margin (`modify_selection` `expand`), then
123
+ `content_aware_fill` `output: "new-layer"`; try another `seed` if the fill repeats texture,
124
+ and mask out what is wrong.
125
+ - **Outline a cutout:** `select_layer_transparency` on it, then `stroke_selection`
126
+ `location: "outside"` on a new layer below it.
127
+ - **Crop to a subject:** select it, then `crop_to_selection` (non-destructive).
128
+ - **Put a picture into a shape:** select the shape, `copy_pixels` the picture, then
129
+ `paste_pixels` `mode: "into"`.
130
+ - **Picture inside a frame:** mask the picture with the frame's shape, then
131
+ `set_layer_mask_properties` `linked: false` so the picture moves under a fixed mask; link it
132
+ again afterwards.
133
+
134
+ ## Pitfalls
135
+
136
+ - **Flooding:** a wand or range that covers most of the image. Start low (wand 20–40, range
137
+ 30–60), check `percent`, and grow with `mode: "add"`.
138
+ - **Box instead of outline:** `select_rect` around a subject masks its background too. Trace
139
+ the contour.
140
+ - **Over-feathering hard objects:** a 10 px feather on a product looks like a glow. Keep hard
141
+ edges at 0–2 px and refine soft ones instead.
142
+ - **Halo:** the old background shows as a light or dark fringe. `contract` 1–2 px or
143
+ `shiftEdge` negative before masking.
144
+ - **Baking too early:** `apply_layer_mask`, `merge_down` and `layer_via_copy` with `cut: true`
145
+ are hard to revise. Keep masks until the user is happy.
146
+ - **Expand is not Grow:** `modify_selection` `expand` moves the edge by distance;
147
+ `grow_selection` adds similar colour. Use the one that matches the problem.
148
+ - **Deselected by mistake:** `reselect` brings it back (or `undo_image`).
149
+ - **Empty selection:** `modify_selection`, `refine_selection` and `apply_selection_as_mask` fail
150
+ on it. Select first.
151
+ - **A forgotten selection limits new layers and filters:** `add_adjustment_layer`,
152
+ `apply_effect` and `add_smart_filter` mask themselves by it. `deselect` first for a global
153
+ change, or pass `useSelection: false`.
154
+ - **Hidden selection still applies:** with `set_selection_display` `none`, paint and fills are
155
+ still limited to it. `deselect` before a whole-layer edit.
156
+ - **Wrong coordinates:** use natural image pixels, not preview pixels. On a cropped or rotated
157
+ image, a rectangle measured in the preview lands in the wrong place.
158
+ - **Deprecated tools:** `select_region` and `select_by_color` still work, but use the tools
159
+ below.
160
+
161
+ ## Tools used
162
+
163
+ - `get_selection`: empty, bounds, area and percent after every step
164
+ - `select_all`, `deselect`, `invert_selection`: whole-image selections
165
+ - `select_rect`, `select_ellipse`: marquees
166
+ - `select_polygon`: the lasso, along a contour
167
+ - `select_line`: a single row or column
168
+ - `select_layer_transparency`: a layer's own pixels
169
+ - `grow_selection`, `select_similar`: add similar colour, connected or anywhere
170
+ - `reselect`: undo a deselect
171
+ - `magic_wand`: similar colour from a seed
172
+ - `select_color_range`: colour samples, hue, tone and skin presets
173
+ - `select_subject`: a subject by description (needs a host model)
174
+ - `load_selection_from_image`: AI or saved mattes
175
+ - `load_selection_from_mask`: a layer mask back to a selection
176
+ - `set_selection_display`: ants, Quick Mask tint or hidden
177
+ - `modify_selection`: expand, contract, feather, border, smooth
178
+ - `refine_selection`: snap the edge to the image
179
+ - `transform_selection`: move or scale the outline only
180
+ - `capture_view`: inspect the edge at pixel level
181
+ - `render_preview`: check the result
182
+ - `apply_selection_as_mask`: a masked adjustment layer in one step
183
+ - `add_layer_mask`, `set_layer_mask_properties`, `apply_layer_mask`, `remove_layer_mask`: layer masks
184
+ - `set_smart_filter_mask`: limit smart filters
185
+ - `layer_via_copy`: lift the selection onto a new layer
186
+ - `stroke_selection`: an outline along the selection edge
187
+ - `crop_to_selection`: crop to the selection's bounds
188
+ - `content_aware_fill`: remove what is selected
189
+ - `copy_pixels`, `cut_pixels`, `paste_pixels`: the editor clipboard
190
+ - `add_adjustment_layer`, `apply_effect`, `add_smart_filter`: masked by an active selection
191
+ - `paint_stroke`: paint on a mask with `channel: "mask"`
192
+ - `undo_image`: take back a step
193
+ - `set_layer_properties`: clipping