@xprite/pixelate 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/NOTICE.md +12 -0
- package/README.md +270 -2
- package/README.zh-CN.md +240 -0
- package/dist/analyze.d.ts +8 -0
- package/dist/analyze.js +217 -0
- package/dist/base.d.ts +18 -0
- package/dist/base.js +42 -0
- package/dist/cell-color-picker.d.ts +14 -0
- package/dist/cell-color-picker.js +278 -0
- package/dist/color-lab.d.ts +3 -0
- package/dist/color-lab.js +31 -0
- package/dist/color-step.d.ts +33 -0
- package/dist/color-step.js +62 -0
- package/dist/contours.d.ts +4 -0
- package/dist/contours.js +66 -0
- package/dist/denoise.d.ts +3 -0
- package/dist/denoise.js +37 -0
- package/dist/deskew.d.ts +24 -0
- package/dist/deskew.js +202 -0
- package/dist/grid-ac-rl-consensus.d.ts +127 -0
- package/dist/grid-ac-rl-consensus.js +497 -0
- package/dist/grid-arbitrate.d.ts +52 -0
- package/dist/grid-arbitrate.js +366 -0
- package/dist/grid-cut-snap.d.ts +15 -0
- package/dist/grid-cut-snap.js +77 -0
- package/dist/grid-description-length.d.ts +47 -0
- package/dist/grid-description-length.js +697 -0
- package/dist/grid-detect.d.ts +8 -0
- package/dist/grid-detect.js +665 -0
- package/dist/grid-edge-coherence.d.ts +4 -0
- package/dist/grid-edge-coherence.js +158 -0
- package/dist/grid-edge-path.d.ts +9 -0
- package/dist/grid-edge-path.js +201 -0
- package/dist/grid-frame-lattice.d.ts +25 -0
- package/dist/grid-frame-lattice.js +420 -0
- package/dist/grid-frequency-spectrum.d.ts +11 -0
- package/dist/grid-frequency-spectrum.js +89 -0
- package/dist/grid-period-boundary.d.ts +13 -0
- package/dist/grid-period-boundary.js +255 -0
- package/dist/grid-period-comb.d.ts +4 -0
- package/dist/grid-period-comb.js +230 -0
- package/dist/grid-period-distance.d.ts +7 -0
- package/dist/grid-period-distance.js +233 -0
- package/dist/grid-phase-field.d.ts +11 -0
- package/dist/grid-phase-field.js +446 -0
- package/dist/grid-pitch-lattice.d.ts +4 -0
- package/dist/grid-pitch-lattice.js +255 -0
- package/dist/grid-pitch-search.d.ts +11 -0
- package/dist/grid-pitch-search.js +233 -0
- package/dist/grid-sample.d.ts +4 -0
- package/dist/grid-sample.js +164 -0
- package/dist/grid-sampling.d.ts +13 -0
- package/dist/grid-sampling.js +132 -0
- package/dist/grid-strip-shift.d.ts +44 -0
- package/dist/grid-strip-shift.js +223 -0
- package/dist/grid-test-images.d.ts +69 -0
- package/dist/grid-test-images.js +547 -0
- package/dist/grid-warp.d.ts +38 -0
- package/dist/grid-warp.js +252 -0
- package/dist/grid.d.ts +8 -0
- package/dist/grid.js +43 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +14 -0
- package/dist/line-guided/cv-lab.d.ts +4 -0
- package/dist/line-guided/cv-lab.js +134 -0
- package/dist/line-guided/cv-ops.d.ts +29 -0
- package/dist/line-guided/cv-ops.js +759 -0
- package/dist/line-guided/pixeloe-entry.d.ts +15 -0
- package/dist/line-guided/pixeloe-entry.js +122 -0
- package/dist/line-guided/pixeloe-legacy.d.ts +31 -0
- package/dist/line-guided/pixeloe-legacy.js +301 -0
- package/dist/line-guided/xdog.d.ts +7 -0
- package/dist/line-guided/xdog.js +84 -0
- package/dist/most-frequent.d.ts +3 -0
- package/dist/most-frequent.js +56 -0
- package/dist/outline-prepass.d.ts +37 -0
- package/dist/outline-prepass.js +56 -0
- package/dist/palette-snap.d.ts +4 -0
- package/dist/palette-snap.js +371 -0
- package/dist/palette.d.ts +21 -0
- package/dist/palette.js +280 -0
- package/dist/pixelate.d.ts +15 -0
- package/dist/pixelate.js +214 -0
- package/dist/pixelation-algorithm-registry.d.ts +34 -0
- package/dist/pixelation-algorithm-registry.js +716 -0
- package/dist/pixeloe-prepass.d.ts +12 -0
- package/dist/pixeloe-prepass.js +527 -0
- package/dist/quantization.d.ts +6 -0
- package/dist/quantization.js +145 -0
- package/dist/remove-background.d.ts +40 -0
- package/dist/remove-background.js +229 -0
- package/dist/resize.d.ts +3 -0
- package/dist/resize.js +86 -0
- package/dist/sampling.d.ts +7 -0
- package/dist/sampling.js +301 -0
- package/dist/settings.d.ts +36 -0
- package/dist/settings.js +181 -0
- package/dist/types.d.ts +255 -0
- package/dist/types.js +87 -0
- package/licenses/PixelOE-Apache-2.0.txt +201 -0
- package/licenses/pixel-art-fixer-MIT.txt +21 -0
- package/licenses/proper-pixel-art-MIT.txt +21 -0
- package/licenses/tensorhead-dithering-MIT.txt +21 -0
- package/package.json +62 -4
- package/wasm/ac-rl-detect-browser-worker.js +45 -0
- package/wasm/ac-rl-detect-worker.mjs +51 -0
- package/wasm/pixelfixer_detect.d.ts +65 -0
- package/wasm/pixelfixer_detect.js +334 -0
- package/wasm/pixelfixer_detect_bg.wasm +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 rhinoc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
| Part | Source | License | Text |
|
|
4
|
+
| --- | --- | --- | --- |
|
|
5
|
+
| `wasm/` and `wasm-src/`: AC+RL grid-count consensus (`acf`, `autocorr`, `runlengths`, `gray`, `sigproc`), made sequential and compiled to WebAssembly | [Retro-Diffusion/pixel-art-fixer](https://github.com/Retro-Diffusion/pixel-art-fixer), Copyright (c) 2026 Astropulse, LLC | MIT | [licenses/pixel-art-fixer-MIT.txt](licenses/pixel-art-fixer-MIT.txt) |
|
|
6
|
+
| `src/line-guided/pixeloe-legacy.ts`, `cv-ops.ts`, `cv-lab.ts`: port of PixelOE's legacy `pixelize()` | [KohakuBlueleaf/PixelOE](https://github.com/KohakuBlueleaf/PixelOE) | Apache-2.0 | [licenses/PixelOE-Apache-2.0.txt](licenses/PixelOE-Apache-2.0.txt) |
|
|
7
|
+
| `src/pixeloe-prepass.ts`: port of PixelOE's outline expansion and colour match (`torch/outline.py`, `torch/color.py`); `src/cell-color-picker.ts`: its contrast-based downscale | [KohakuBlueleaf/PixelOE](https://github.com/KohakuBlueleaf/PixelOE) | Apache-2.0 | [licenses/PixelOE-Apache-2.0.txt](licenses/PixelOE-Apache-2.0.txt) |
|
|
8
|
+
| `src/grid-detect.ts`: the edge-mesh idea (anchor cuts on projected edges, fill gaps at an even pitch); `src/cell-color-picker.ts`: per-cell colour choice and output colour merging | [KennethJAllen/proper-pixel-art](https://github.com/KennethJAllen/proper-pixel-art), Copyright (c) 2024 Kenneth Allen | MIT | [licenses/proper-pixel-art-MIT.txt](licenses/proper-pixel-art-MIT.txt) |
|
|
9
|
+
| `src/palette-snap.ts`: Bayer 8x8 matrix and ordered dithering to a palette (`matrices.rs`, `ordered.rs`) | [tensorhead/dithering](https://github.com/tensorhead/dithering) | MIT | [licenses/tensorhead-dithering-MIT.txt](licenses/tensorhead-dithering-MIT.txt) |
|
|
10
|
+
|
|
11
|
+
The PixelOE ports are modified versions: they were rewritten from Python, OpenCV and NumPy into
|
|
12
|
+
TypeScript, and the legacy port's expansion weight can be replaced by a line guide.
|
package/README.md
CHANGED
|
@@ -1,3 +1,271 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @xprite/pixelate
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@xprite/pixelate)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
English | [简体中文](https://github.com/rhinoc/xprite-pixelate/blob/main/README.zh-CN.md)
|
|
7
|
+
|
|
8
|
+
Recover the real pixel grid of AI-generated pixel art and get back one clean pixel per cell. It
|
|
9
|
+
also turns ordinary images into pixel art. It runs in browsers and Node, has no runtime
|
|
10
|
+
dependencies, and is the importer of the [Xprite](https://xprite.cc) pixel editor.
|
|
11
|
+
|
|
12
|
+
## Compared with other tools
|
|
13
|
+
|
|
14
|
+
A real generated image (887×887, cells 15 to 21 px wide), recovered by each tool with its default
|
|
15
|
+
settings. Xprite puts each cut on a colour edge, so it does not cut through the eye, the boots or
|
|
16
|
+
the sword.
|
|
17
|
+
|
|
18
|
+
| Recovered grid | Xprite, 48×49 | [pixel-art-fixer](https://github.com/Retro-Diffusion/pixel-art-fixer), 47×48 | [perfectPixel](https://github.com/theamusing/perfectPixel), 50×50 | [proper-pixel-art](https://github.com/KennethJAllen/proper-pixel-art), 53×54 |
|
|
19
|
+
| :---: | :---: | :---: | :---: | :---: |
|
|
20
|
+
|  |  |  |  |  |
|
|
21
|
+
|
|
22
|
+
On the AI suite of [our benchmark](#benchmark) (1746 cases), Xprite gets the exact size most
|
|
23
|
+
often:
|
|
24
|
+
|
|
25
|
+
| Method | Exact size | Within 1 cell | Pixel match | Half-transparent fringe | Median time |
|
|
26
|
+
| --- | --- | --- | --- | --- | --- |
|
|
27
|
+
| Xprite Auto | **83.6%** | **90.0%** | **99.8%** | 0.1% | 1.55 s |
|
|
28
|
+
| pixel-art-fixer | 49.7% | 80.9% | 98.3% | 0.0% | 0.18 s |
|
|
29
|
+
| perfectPixel | 53.3% | 68.0% | 96.7% | - | 0.03 s |
|
|
30
|
+
| proper-pixel-art | 72.2% | 80.4% | 99.7% | 0.0% | 0.49 s |
|
|
31
|
+
|
|
32
|
+
## Contents
|
|
33
|
+
|
|
34
|
+
- [Examples](#examples)
|
|
35
|
+
- [Install](#install)
|
|
36
|
+
- [Usage](#usage)
|
|
37
|
+
- [How it works](#how-it-works)
|
|
38
|
+
- [Benchmark](#benchmark)
|
|
39
|
+
- [License](#license)
|
|
40
|
+
|
|
41
|
+
## Examples
|
|
42
|
+
|
|
43
|
+
Each example is one case from a category of the benchmark's AI suite: CC0 pixel art rendered the
|
|
44
|
+
way generators fake it, with a known native size. The sizes are the visible art in cells; ✓ marks
|
|
45
|
+
the exact native size. Every tool runs with its default settings.
|
|
46
|
+
|
|
47
|
+
### Two sprites on one canvas
|
|
48
|
+
|
|
49
|
+
- [Goblins by LuizMelo](https://luizmelo.itch.io/monsters-creatures-fantasy), CC0. Category `gen_pair`. Native art: 78×36.
|
|
50
|
+
|
|
51
|
+
| Input, 1800×845 | Xprite, 78×36 ✓ | pixel-art-fixer, 78×35 ✗ | perfectPixel, 80×36 ✗ | proper-pixel-art, 79×36 ✗ |
|
|
52
|
+
| :---: | :---: | :---: | :---: | :---: |
|
|
53
|
+
|  |  |  |  |  |
|
|
54
|
+
|
|
55
|
+
### Cells that drift and jitter
|
|
56
|
+
|
|
57
|
+
- [Boss dragon by ansimuz](https://opengameart.org/content/sideview-fantasy-patreon-collection), CC0. Category `gen_wobble`. Native art: 71×39.
|
|
58
|
+
|
|
59
|
+
| Input, 1226×664 | Xprite, 71×39 ✓ | pixel-art-fixer, 69×38 ✗ | perfectPixel, 74×39 ✗ | proper-pixel-art, 69×38 ✗ |
|
|
60
|
+
| :---: | :---: | :---: | :---: | :---: |
|
|
61
|
+
|  |  |  |  |  |
|
|
62
|
+
|
|
63
|
+
### Small cells and WebP damage
|
|
64
|
+
|
|
65
|
+
- [Monster by Denzi](https://opengameart.org/content/denzis-public-domain-art), CC0. Category `gen_small_pitch`. Native art: 32×48.
|
|
66
|
+
|
|
67
|
+
| Input, 218×339 | Xprite, 32×48 ✓ | pixel-art-fixer, 32×47 ✗ | perfectPixel, 32×49 ✗ | proper-pixel-art, 34×49 ✗ |
|
|
68
|
+
| :---: | :---: | :---: | :---: | :---: |
|
|
69
|
+
|  |  |  |  |  |
|
|
70
|
+
|
|
71
|
+
### A small sprite on a large clear canvas
|
|
72
|
+
|
|
73
|
+
- [Nekomimi girl by cawfeecrow](https://opengameart.org/content/nekomimi-girl-portrait), CC0. Category `gen_sparse`. Native art: 123×136.
|
|
74
|
+
|
|
75
|
+
| Input, 1797×1800 | Xprite, 123×136 ✓ | pixel-art-fixer, 122×136 ✗ | perfectPixel, 124×136 ✗ | proper-pixel-art, 127×142 ✗ |
|
|
76
|
+
| :---: | :---: | :---: | :---: | :---: |
|
|
77
|
+
|  |  |  |  |  |
|
|
78
|
+
|
|
79
|
+
### An off-white background
|
|
80
|
+
|
|
81
|
+
- [Dragon by ansimuz](https://opengameart.org/content/sideview-fantasy-patreon-collection), CC0. Category `gen_white`. Native art: 162×106.
|
|
82
|
+
|
|
83
|
+
| Input, 1800×1210 | Xprite, 162×106 ✓ | pixel-art-fixer, 325×208 ✗ | perfectPixel, 161×105 ✗ | proper-pixel-art, 168×106 ✗ |
|
|
84
|
+
| :---: | :---: | :---: | :---: | :---: |
|
|
85
|
+
|  |  |  |  |  |
|
|
86
|
+
|
|
87
|
+
### Painterly shading inside cells
|
|
88
|
+
|
|
89
|
+
- [Naga mage, Dungeon Crawl Stone Soup](https://github.com/crawl/tiles), CC0. Category `gen_painterly`. Native art: 31×32.
|
|
90
|
+
|
|
91
|
+
| Input, 411×425 | Xprite, 31×32 ✓ | pixel-art-fixer, 30×33 ✗ | perfectPixel, 31×32 ✓ | proper-pixel-art, 31×34 ✗ |
|
|
92
|
+
| :---: | :---: | :---: | :---: | :---: |
|
|
93
|
+
|  |  |  |  |  |
|
|
94
|
+
|
|
95
|
+
## Install
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npm install @xprite/pixelate
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Usage
|
|
102
|
+
|
|
103
|
+
An image is `{ width, height, data }`, where `data` holds RGBA bytes, row by row, with straight
|
|
104
|
+
alpha. `ImageData` from a canvas has this shape.
|
|
105
|
+
|
|
106
|
+
### Recover a grid
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import {
|
|
110
|
+
CellColorPicker,
|
|
111
|
+
PixelationAlgorithm,
|
|
112
|
+
PixelationMode,
|
|
113
|
+
detectWithAlgorithm,
|
|
114
|
+
pixelateImage,
|
|
115
|
+
preloadWasm,
|
|
116
|
+
} from "@xprite/pixelate";
|
|
117
|
+
|
|
118
|
+
await preloadWasm(); // optional: loads the grid-count detector once, before the first image
|
|
119
|
+
|
|
120
|
+
const image = { width, height, data: new Uint8ClampedArray(rgba) };
|
|
121
|
+
|
|
122
|
+
const grid = detectWithAlgorithm(image, PixelationAlgorithm.Auto);
|
|
123
|
+
if (grid.reliable) {
|
|
124
|
+
const art = pixelateImage(image, {
|
|
125
|
+
mode: PixelationMode.RecoverGrid,
|
|
126
|
+
grid,
|
|
127
|
+
colorPicker: CellColorPicker.TwoStage,
|
|
128
|
+
paletteSnap: { adaptive: true }, // merge the near-shades a generator leaves behind
|
|
129
|
+
});
|
|
130
|
+
// art.width × art.height is the native size: one pixel per recovered cell.
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
`grid.reliable` is false when the image has no consistent grid (a photo, a drawing, or real 1×
|
|
135
|
+
pixel art). `RecoverGrid` mode throws an error for such a grid. Use `Convert` mode for those
|
|
136
|
+
images.
|
|
137
|
+
|
|
138
|
+
### Convert an image
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
const art = pixelateImage(photo, {
|
|
142
|
+
mode: PixelationMode.Convert,
|
|
143
|
+
targetSize: { width: 64, height: 64 },
|
|
144
|
+
paletteSnap: { colors: 16 },
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Remove a flat background
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
import { removeBackground } from "@xprite/pixelate";
|
|
152
|
+
|
|
153
|
+
const clear = removeBackground(image); // keys the most common border colour
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Call it before detection when a generator painted a white or checkerboard background.
|
|
157
|
+
|
|
158
|
+
### Options
|
|
159
|
+
|
|
160
|
+
`pixelateImage(image, options)`:
|
|
161
|
+
|
|
162
|
+
| Option | Description |
|
|
163
|
+
| --- | --- |
|
|
164
|
+
| `mode` | `RecoverGrid` uses a detected grid. `Convert` makes pixel art at a size you give. |
|
|
165
|
+
| `grid` | A grid from `detectWithAlgorithm`. If you omit it, the grid is detected with `algorithm`. |
|
|
166
|
+
| `algorithm` | Grid detector. `Auto` runs all of them and picks one grid. |
|
|
167
|
+
| `colorPicker` | Colour rule per cell: `TwoStage`, `MostCommon` (default), `Median`, `Average`, `KMeans`, `Contrast` and others. |
|
|
168
|
+
| `targetSize`, `targetWidth`, `targetHeight`, `blockSize` | Output size in `Convert` mode. |
|
|
169
|
+
| `paletteSnap` | Limit colours: `{ adaptive: true }`, `{ colors: 16 }` or `{ palette: [...] }`, with optional `dither`. |
|
|
170
|
+
| `prepass` | Outline pre-pass from PixelOE (`Pixeloe`, `PixeloeLines`). |
|
|
171
|
+
| `removeNoise` | Light smoothing of similar neighbour colours. |
|
|
172
|
+
| `preserveDimensions` | Scale the result back up to the source size, nearest neighbour. |
|
|
173
|
+
|
|
174
|
+
[`src/types.ts`](src/types.ts) documents every option.
|
|
175
|
+
|
|
176
|
+
### Workers
|
|
177
|
+
|
|
178
|
+
`detectWithAlgorithm` and `pixelateImage` are synchronous and can take a few seconds on large
|
|
179
|
+
images, so run them in a Web Worker. In a browser, Auto can also run its grid-count detector in a
|
|
180
|
+
nested worker, in parallel with the other detectors:
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
import { setAcRlBrowserWorkerFactory, detectWithAlgorithmAsync } from "@xprite/pixelate";
|
|
184
|
+
|
|
185
|
+
setAcRlBrowserWorkerFactory(
|
|
186
|
+
() =>
|
|
187
|
+
new Worker(
|
|
188
|
+
new URL("@xprite/pixelate/wasm/ac-rl-detect-browser-worker.js", import.meta.url),
|
|
189
|
+
{ type: "module" },
|
|
190
|
+
),
|
|
191
|
+
);
|
|
192
|
+
const grid = await detectWithAlgorithmAsync(image);
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
In Node, the detector starts a `worker_threads` worker from `wasm/ac-rl-detect-worker.mjs` by
|
|
196
|
+
itself. Set `XPRITE_AC_RL_WORKER=0` to keep it on the calling thread.
|
|
197
|
+
|
|
198
|
+
## How it works
|
|
199
|
+
|
|
200
|
+
1. **Straighten.** Auto estimates the tilt. When the tilt is clear, it detects on a straightened
|
|
201
|
+
copy.
|
|
202
|
+
2. **Propose.** Seven detectors propose grids: uniform grid, edge grid, frame lattice, pitch
|
|
203
|
+
lattice, colour period, border runs and edge spacing. A WebAssembly port of pixel-art-fixer's
|
|
204
|
+
autocorrelation and run-length vote gives an independent cell count.
|
|
205
|
+
3. **Follow the edges.** At each pitch the detectors keep, a dynamic program walks each axis and
|
|
206
|
+
puts every cut on a colour edge. Each cell stays within 0.75 to 1.25 of the pitch, and a change
|
|
207
|
+
of width costs extra. This step handles cells of uneven width.
|
|
208
|
+
4. **Filter.** A candidate is dropped when its cuts miss the colour edges that a coarser grid
|
|
209
|
+
follows.
|
|
210
|
+
5. **Choose.** The grid that describes the image in the fewest bits wins (minimum description
|
|
211
|
+
length). A grid that is not locked to the content's phase pays a penalty. Drift and sheared
|
|
212
|
+
rows are read as strip shifts or as a phase field.
|
|
213
|
+
6. **Sample.** Each cell gets one colour (`TwoStage` packs the cell's colours in two steps).
|
|
214
|
+
Adaptive palette snapping then merges near-duplicate shades.
|
|
215
|
+
7. **Settle alpha.** Cells that the art covers become fully opaque, and cells outside the art
|
|
216
|
+
become clear.
|
|
217
|
+
|
|
218
|
+
Each source file in [`src/`](src) describes its step.
|
|
219
|
+
|
|
220
|
+
## Benchmark
|
|
221
|
+
|
|
222
|
+
[`bench/`](bench) compares this package with three other tools on CC0 native pixel art. The
|
|
223
|
+
benchmark damages the art in known ways and scores each result against the original. Every tool
|
|
224
|
+
runs with its default settings.
|
|
225
|
+
|
|
226
|
+
AI suite (1746 cases in 12 categories, rendered the way generators fake pixel art):
|
|
227
|
+
|
|
228
|
+
| Method | Exact size | Within 1 cell | Pixel match | ΔE | Half-transparent fringe | Median time |
|
|
229
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
230
|
+
| Xprite Auto | **83.6%** | **90.0%** | **99.8%** | 0.82 | 0.1% | 1.55 s |
|
|
231
|
+
| pixel-art-fixer | 49.7% | 80.9% | 98.3% | 1.74 | 0.0% | 0.18 s |
|
|
232
|
+
| perfectPixel | 53.3% | 68.0% | 96.7% | 2.42 | - | 0.03 s |
|
|
233
|
+
| proper-pixel-art | 72.2% | 80.4% | 99.7% | **0.64** | 0.0% | 0.49 s |
|
|
234
|
+
|
|
235
|
+
Exact size per category:
|
|
236
|
+
|
|
237
|
+
| Category | Xprite | pixel-art-fixer | perfectPixel | proper-pixel-art |
|
|
238
|
+
| --- | --- | --- | --- | --- |
|
|
239
|
+
| Clean (`gen_clean`) | **93.6%** | 71.7% | 58.4% | 74.6% |
|
|
240
|
+
| Sparse canvas (`gen_sparse`) | **99.0%** | 63.5% | 71.9% | 88.5% |
|
|
241
|
+
| Off-white background (`gen_white`) | 77.7% | 65.2% | 66.1% | **82.1%** |
|
|
242
|
+
| Soft outline (`gen_soft_edge`) | **95.8%** | 61.9% | 67.8% | 82.2% |
|
|
243
|
+
| Drift and WebP (`gen_webp`) | **80.9%** | 40.5% | 57.8% | 71.1% |
|
|
244
|
+
| Halos and JPEG (`gen_halo_jpeg`) | **82.7%** | 52.6% | 60.1% | 72.8% |
|
|
245
|
+
| Painterly shading (`gen_painterly`) | **84.5%** | 39.1% | 67.8% | 79.3% |
|
|
246
|
+
| Small cells (4-8 px) (`gen_small_pitch`) | **72.2%** | 47.9% | 40.2% | 43.8% |
|
|
247
|
+
| Large cells (24-48 px) (`gen_large_pitch`) | 68.2% | 22.0% | 68.2% | **78.0%** |
|
|
248
|
+
| Strong drift (`gen_wobble`) | **73.3%** | 30.8% | 30.8% | 54.1% |
|
|
249
|
+
| Two sprites (`gen_pair`) | **97.1%** | 62.7% | 45.1% | 72.5% |
|
|
250
|
+
| Drop shadow (`gen_shadow`) | **97.3%** | 64.0% | 0.0% | 84.7% |
|
|
251
|
+
|
|
252
|
+
[pixel-bench](https://github.com/Retro-Diffusion/pixel-bench) suite v1 (7651 cases of upscales and
|
|
253
|
+
lossy pipelines):
|
|
254
|
+
|
|
255
|
+
| Method | Exact size | Within 1 cell | Pixel match | ΔE | Median time |
|
|
256
|
+
| --- | --- | --- | --- | --- | --- |
|
|
257
|
+
| Xprite Auto | **87.1%** | **90.1%** | 94.3% | **2.79** | 0.24 s |
|
|
258
|
+
| pixel-art-fixer | 77.8% | 83.5% | **94.4%** | 2.83 | 0.04 s |
|
|
259
|
+
| perfectPixel | 24.2% | 32.9% | 89.7% | 4.31 | 0.002 s |
|
|
260
|
+
| proper-pixel-art | 16.5% | 28.6% | 93.0% | 3.85 | 0.05 s |
|
|
261
|
+
|
|
262
|
+
Pixel match and ΔE are measured only on the cases with the exact size. Xprite is the slowest of
|
|
263
|
+
the four tools. The damage is synthetic, so the scores show how the tools rank on these features,
|
|
264
|
+
not how often they succeed on real images. [bench/README.md](bench/README.md) gives the method,
|
|
265
|
+
the categories and the steps to run it.
|
|
266
|
+
|
|
267
|
+
## License
|
|
268
|
+
|
|
269
|
+
MIT. Parts are adapted from pixel-art-fixer, PixelOE, proper-pixel-art and tensorhead/dithering
|
|
270
|
+
(see [NOTICE.md](NOTICE.md)). The example art is CC0 (see
|
|
271
|
+
[bench/corpus/CREDITS.md](bench/corpus/CREDITS.md)).
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# @xprite/pixelate
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@xprite/pixelate)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
[English](https://github.com/rhinoc/xprite-pixelate/blob/main/README.md) | 简体中文
|
|
7
|
+
|
|
8
|
+
找出 AI 生成像素画中真正的像素网格,每一格还原成一个干净的像素。它也能把普通图片转成像素画。它可以在浏览器和 Node 中运行,没有运行时依赖,是像素编辑器 [Xprite](https://xprite.cc) 的导入器。
|
|
9
|
+
|
|
10
|
+
## 与其他工具对比
|
|
11
|
+
|
|
12
|
+
一张真实的 AI 生成图(887×887,格宽 15 到 21 像素不等),各工具用默认设置还原的结果。Xprite 把每一刀都切在颜色边缘上,所以不会切开眼睛、靴子和剑。
|
|
13
|
+
|
|
14
|
+
| 找到的网格 | Xprite,48×49 | [pixel-art-fixer](https://github.com/Retro-Diffusion/pixel-art-fixer),47×48 | [perfectPixel](https://github.com/theamusing/perfectPixel),50×50 | [proper-pixel-art](https://github.com/KennethJAllen/proper-pixel-art),53×54 |
|
|
15
|
+
| :---: | :---: | :---: | :---: | :---: |
|
|
16
|
+
|  |  |  |  |  |
|
|
17
|
+
|
|
18
|
+
在[我们的基准测试](#基准测试)的 AI 套件(1746 个用例)上,Xprite 得到正确尺寸的次数最多:
|
|
19
|
+
|
|
20
|
+
| 方法 | 尺寸完全正确 | 差 1 格以内 | 像素一致率 | 半透明毛边 | 中位耗时 |
|
|
21
|
+
| --- | --- | --- | --- | --- | --- |
|
|
22
|
+
| Xprite Auto | **83.6%** | **90.0%** | **99.8%** | 0.1% | 1.55 s |
|
|
23
|
+
| pixel-art-fixer | 49.7% | 80.9% | 98.3% | 0.0% | 0.18 s |
|
|
24
|
+
| perfectPixel | 53.3% | 68.0% | 96.7% | - | 0.03 s |
|
|
25
|
+
| proper-pixel-art | 72.2% | 80.4% | 99.7% | 0.0% | 0.49 s |
|
|
26
|
+
|
|
27
|
+
## 目录
|
|
28
|
+
|
|
29
|
+
- [示例](#示例)
|
|
30
|
+
- [安装](#安装)
|
|
31
|
+
- [用法](#用法)
|
|
32
|
+
- [原理](#原理)
|
|
33
|
+
- [基准测试](#基准测试)
|
|
34
|
+
- [许可证](#许可证)
|
|
35
|
+
|
|
36
|
+
## 示例
|
|
37
|
+
|
|
38
|
+
每个示例取自基准测试 AI 套件的一个类别:把 CC0 像素画按生成模型的方式渲染,原画尺寸已知。尺寸是可见画面的格数,✓ 表示与原画尺寸完全一致。每个工具都使用默认设置。
|
|
39
|
+
|
|
40
|
+
### 一张画布上的两个角色
|
|
41
|
+
|
|
42
|
+
- [哥布林,作者 LuizMelo](https://luizmelo.itch.io/monsters-creatures-fantasy),CC0。类别 `gen_pair`。原画:78×36。
|
|
43
|
+
|
|
44
|
+
| 输入,1800×845 | Xprite,78×36 ✓ | pixel-art-fixer,78×35 ✗ | perfectPixel,80×36 ✗ | proper-pixel-art,79×36 ✗ |
|
|
45
|
+
| :---: | :---: | :---: | :---: | :---: |
|
|
46
|
+
|  |  |  |  |  |
|
|
47
|
+
|
|
48
|
+
### 格子漂移和抖动
|
|
49
|
+
|
|
50
|
+
- [巨龙,作者 ansimuz](https://opengameart.org/content/sideview-fantasy-patreon-collection),CC0。类别 `gen_wobble`。原画:71×39。
|
|
51
|
+
|
|
52
|
+
| 输入,1226×664 | Xprite,71×39 ✓ | pixel-art-fixer,69×38 ✗ | perfectPixel,74×39 ✗ | proper-pixel-art,69×38 ✗ |
|
|
53
|
+
| :---: | :---: | :---: | :---: | :---: |
|
|
54
|
+
|  |  |  |  |  |
|
|
55
|
+
|
|
56
|
+
### 小格子和 WebP 压缩损伤
|
|
57
|
+
|
|
58
|
+
- [怪物,作者 Denzi](https://opengameart.org/content/denzis-public-domain-art),CC0。类别 `gen_small_pitch`。原画:32×48。
|
|
59
|
+
|
|
60
|
+
| 输入,218×339 | Xprite,32×48 ✓ | pixel-art-fixer,32×47 ✗ | perfectPixel,32×49 ✗ | proper-pixel-art,34×49 ✗ |
|
|
61
|
+
| :---: | :---: | :---: | :---: | :---: |
|
|
62
|
+
|  |  |  |  |  |
|
|
63
|
+
|
|
64
|
+
### 大块透明画布上的小角色
|
|
65
|
+
|
|
66
|
+
- [猫耳少女,作者 cawfeecrow](https://opengameart.org/content/nekomimi-girl-portrait),CC0。类别 `gen_sparse`。原画:123×136。
|
|
67
|
+
|
|
68
|
+
| 输入,1797×1800 | Xprite,123×136 ✓ | pixel-art-fixer,122×136 ✗ | perfectPixel,124×136 ✗ | proper-pixel-art,127×142 ✗ |
|
|
69
|
+
| :---: | :---: | :---: | :---: | :---: |
|
|
70
|
+
|  |  |  |  |  |
|
|
71
|
+
|
|
72
|
+
### 近白色背景
|
|
73
|
+
|
|
74
|
+
- [飞龙,作者 ansimuz](https://opengameart.org/content/sideview-fantasy-patreon-collection),CC0。类别 `gen_white`。原画:162×106。
|
|
75
|
+
|
|
76
|
+
| 输入,1800×1210 | Xprite,162×106 ✓ | pixel-art-fixer,325×208 ✗ | perfectPixel,161×105 ✗ | proper-pixel-art,168×106 ✗ |
|
|
77
|
+
| :---: | :---: | :---: | :---: | :---: |
|
|
78
|
+
|  |  |  |  |  |
|
|
79
|
+
|
|
80
|
+
### 格内有绘画式明暗
|
|
81
|
+
|
|
82
|
+
- [娜迦法师,Dungeon Crawl Stone Soup](https://github.com/crawl/tiles),CC0。类别 `gen_painterly`。原画:31×32。
|
|
83
|
+
|
|
84
|
+
| 输入,411×425 | Xprite,31×32 ✓ | pixel-art-fixer,30×33 ✗ | perfectPixel,31×32 ✓ | proper-pixel-art,31×34 ✗ |
|
|
85
|
+
| :---: | :---: | :---: | :---: | :---: |
|
|
86
|
+
|  |  |  |  |  |
|
|
87
|
+
|
|
88
|
+
## 安装
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm install @xprite/pixelate
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 用法
|
|
95
|
+
|
|
96
|
+
图像是 `{ width, height, data }`,`data` 是逐行排列的 RGBA 字节,alpha 未预乘。canvas 的 `ImageData` 就是这个结构。
|
|
97
|
+
|
|
98
|
+
### 还原网格
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import {
|
|
102
|
+
CellColorPicker,
|
|
103
|
+
PixelationAlgorithm,
|
|
104
|
+
PixelationMode,
|
|
105
|
+
detectWithAlgorithm,
|
|
106
|
+
pixelateImage,
|
|
107
|
+
preloadWasm,
|
|
108
|
+
} from "@xprite/pixelate";
|
|
109
|
+
|
|
110
|
+
await preloadWasm(); // 可选:在处理第一张图之前加载格数检测器
|
|
111
|
+
|
|
112
|
+
const image = { width, height, data: new Uint8ClampedArray(rgba) };
|
|
113
|
+
|
|
114
|
+
const grid = detectWithAlgorithm(image, PixelationAlgorithm.Auto);
|
|
115
|
+
if (grid.reliable) {
|
|
116
|
+
const art = pixelateImage(image, {
|
|
117
|
+
mode: PixelationMode.RecoverGrid,
|
|
118
|
+
grid,
|
|
119
|
+
colorPicker: CellColorPicker.TwoStage,
|
|
120
|
+
paletteSnap: { adaptive: true }, // 合并生成模型留下的相近色
|
|
121
|
+
});
|
|
122
|
+
// art.width × art.height 是原生尺寸:每个格子一个像素。
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
图里没有一致的网格时(照片、手绘,或本来就是 1× 的像素画),`grid.reliable` 为 false,`RecoverGrid` 模式会对这种网格抛出错误。这类图片请用 `Convert` 模式。
|
|
127
|
+
|
|
128
|
+
### 转换图片
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
const art = pixelateImage(photo, {
|
|
132
|
+
mode: PixelationMode.Convert,
|
|
133
|
+
targetSize: { width: 64, height: 64 },
|
|
134
|
+
paletteSnap: { colors: 16 },
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 去除纯色背景
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import { removeBackground } from "@xprite/pixelate";
|
|
142
|
+
|
|
143
|
+
const clear = removeBackground(image); // 以边框上最常见的颜色为键
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
生成模型画了白色或棋盘格背景时,先调用它,再检测网格。
|
|
147
|
+
|
|
148
|
+
### 选项
|
|
149
|
+
|
|
150
|
+
`pixelateImage(image, options)`:
|
|
151
|
+
|
|
152
|
+
| 选项 | 说明 |
|
|
153
|
+
| --- | --- |
|
|
154
|
+
| `mode` | `RecoverGrid` 使用检测到的网格;`Convert` 按给定尺寸生成像素画。 |
|
|
155
|
+
| `grid` | `detectWithAlgorithm` 返回的网格。省略时用 `algorithm` 检测。 |
|
|
156
|
+
| `algorithm` | 网格检测器。`Auto` 运行全部检测器并选出一个网格。 |
|
|
157
|
+
| `colorPicker` | 每格的取色规则:`TwoStage`、`MostCommon`(默认)、`Median`、`Average`、`KMeans`、`Contrast` 等。 |
|
|
158
|
+
| `targetSize`、`targetWidth`、`targetHeight`、`blockSize` | `Convert` 模式的输出尺寸。 |
|
|
159
|
+
| `paletteSnap` | 限制颜色:`{ adaptive: true }`、`{ colors: 16 }` 或 `{ palette: [...] }`,可选 `dither`。 |
|
|
160
|
+
| `prepass` | 来自 PixelOE 的轮廓预处理(`Pixeloe`、`PixeloeLines`)。 |
|
|
161
|
+
| `removeNoise` | 对相近的相邻颜色做轻度平滑。 |
|
|
162
|
+
| `preserveDimensions` | 用最近邻把结果放大回原图尺寸。 |
|
|
163
|
+
|
|
164
|
+
所有选项见 [`src/types.ts`](src/types.ts)。
|
|
165
|
+
|
|
166
|
+
### Worker
|
|
167
|
+
|
|
168
|
+
`detectWithAlgorithm` 和 `pixelateImage` 是同步函数,大图可能要几秒,请在 Web Worker 中运行。在浏览器中,Auto 还可以把格数检测器放进嵌套 Worker,和其他检测器并行:
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
import { setAcRlBrowserWorkerFactory, detectWithAlgorithmAsync } from "@xprite/pixelate";
|
|
172
|
+
|
|
173
|
+
setAcRlBrowserWorkerFactory(
|
|
174
|
+
() =>
|
|
175
|
+
new Worker(
|
|
176
|
+
new URL("@xprite/pixelate/wasm/ac-rl-detect-browser-worker.js", import.meta.url),
|
|
177
|
+
{ type: "module" },
|
|
178
|
+
),
|
|
179
|
+
);
|
|
180
|
+
const grid = await detectWithAlgorithmAsync(image);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
在 Node 中,检测器会自己从 `wasm/ac-rl-detect-worker.mjs` 启动一个 `worker_threads` Worker。设置 `XPRITE_AC_RL_WORKER=0` 可以让它留在调用线程。
|
|
184
|
+
|
|
185
|
+
## 原理
|
|
186
|
+
|
|
187
|
+
1. **扶正。** Auto 先估计倾斜角。倾斜明确时,在扶正后的副本上检测。
|
|
188
|
+
2. **提议。** 七个检测器提议网格:均匀网格、边缘网格、边框晶格、格距晶格、颜色周期、边界游程和边缘间距。pixel-art-fixer 的自相关与游程投票移植成 WebAssembly,给出一个独立的格数。
|
|
189
|
+
3. **沿边缘切。** 在检测器保留的每个格宽上,动态规划沿每条轴走一遍,把每一刀切在颜色边缘上。每格宽度保持在格宽的 0.75 到 1.25 倍之间,宽度变化另有代价。这一步处理宽度不均的格子。
|
|
190
|
+
4. **过滤。** 候选网格的切线若没有落在更粗网格所跟随的颜色边缘上,就被剔除。
|
|
191
|
+
5. **选择。** 描述图像所需比特数最少的网格胜出(最小描述长度)。没有锁定到内容相位的网格要付出额外代价。漂移和错位的行读作条带位移或相位场。
|
|
192
|
+
6. **取色。** 每格取一个颜色(`TwoStage` 分两步归并格内颜色),自适应调色板再合并近似色。
|
|
193
|
+
7. **整理透明度。** 被画覆盖的格子变为完全不透明,画外的格子变为透明。
|
|
194
|
+
|
|
195
|
+
`src/` 中每个源文件都说明了自己负责的步骤,见 [`src/`](src)。
|
|
196
|
+
|
|
197
|
+
## 基准测试
|
|
198
|
+
|
|
199
|
+
[`bench/`](bench) 在 CC0 原生像素画上比较本包和另外三个工具。基准测试以已知方式损伤原画,再把每个结果和原画对比打分。每个工具都使用默认设置。
|
|
200
|
+
|
|
201
|
+
AI 套件(12 个类别共 1746 个用例,按生成模型伪造像素画的方式渲染):
|
|
202
|
+
|
|
203
|
+
| 方法 | 尺寸完全正确 | 差 1 格以内 | 像素一致率 | ΔE | 半透明毛边 | 中位耗时 |
|
|
204
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
205
|
+
| Xprite Auto | **83.6%** | **90.0%** | **99.8%** | 0.82 | 0.1% | 1.55 s |
|
|
206
|
+
| pixel-art-fixer | 49.7% | 80.9% | 98.3% | 1.74 | 0.0% | 0.18 s |
|
|
207
|
+
| perfectPixel | 53.3% | 68.0% | 96.7% | 2.42 | - | 0.03 s |
|
|
208
|
+
| proper-pixel-art | 72.2% | 80.4% | 99.7% | **0.64** | 0.0% | 0.49 s |
|
|
209
|
+
|
|
210
|
+
各类别的尺寸完全正确率:
|
|
211
|
+
|
|
212
|
+
| 类别 | Xprite | pixel-art-fixer | perfectPixel | proper-pixel-art |
|
|
213
|
+
| --- | --- | --- | --- | --- |
|
|
214
|
+
| 干净 (`gen_clean`) | **93.6%** | 71.7% | 58.4% | 74.6% |
|
|
215
|
+
| 稀疏画布 (`gen_sparse`) | **99.0%** | 63.5% | 71.9% | 88.5% |
|
|
216
|
+
| 近白色背景 (`gen_white`) | 77.7% | 65.2% | 66.1% | **82.1%** |
|
|
217
|
+
| 柔和轮廓 (`gen_soft_edge`) | **95.8%** | 61.9% | 67.8% | 82.2% |
|
|
218
|
+
| 漂移和 WebP (`gen_webp`) | **80.9%** | 40.5% | 57.8% | 71.1% |
|
|
219
|
+
| 光晕和 JPEG (`gen_halo_jpeg`) | **82.7%** | 52.6% | 60.1% | 72.8% |
|
|
220
|
+
| 绘画式明暗 (`gen_painterly`) | **84.5%** | 39.1% | 67.8% | 79.3% |
|
|
221
|
+
| 小格子(4-8 px) (`gen_small_pitch`) | **72.2%** | 47.9% | 40.2% | 43.8% |
|
|
222
|
+
| 大格子(24-48 px) (`gen_large_pitch`) | 68.2% | 22.0% | 68.2% | **78.0%** |
|
|
223
|
+
| 强漂移 (`gen_wobble`) | **73.3%** | 30.8% | 30.8% | 54.1% |
|
|
224
|
+
| 两个角色 (`gen_pair`) | **97.1%** | 62.7% | 45.1% | 72.5% |
|
|
225
|
+
| 投影 (`gen_shadow`) | **97.3%** | 64.0% | 0.0% | 84.7% |
|
|
226
|
+
|
|
227
|
+
[pixel-bench](https://github.com/Retro-Diffusion/pixel-bench) v1 套件(7651 个放大和有损处理用例):
|
|
228
|
+
|
|
229
|
+
| 方法 | 尺寸完全正确 | 差 1 格以内 | 像素一致率 | ΔE | 中位耗时 |
|
|
230
|
+
| --- | --- | --- | --- | --- | --- |
|
|
231
|
+
| Xprite Auto | **87.1%** | **90.1%** | 94.3% | **2.79** | 0.24 s |
|
|
232
|
+
| pixel-art-fixer | 77.8% | 83.5% | **94.4%** | 2.83 | 0.04 s |
|
|
233
|
+
| perfectPixel | 24.2% | 32.9% | 89.7% | 4.31 | 0.002 s |
|
|
234
|
+
| proper-pixel-art | 16.5% | 28.6% | 93.0% | 3.85 | 0.05 s |
|
|
235
|
+
|
|
236
|
+
像素一致率和 ΔE 只在尺寸完全正确的用例上统计。四个工具中 Xprite 最慢。损伤是合成的,所以得分反映各工具在这些特征上的排名,不代表在真实图片上的成功率。方法、类别和运行步骤见 [bench/README.md](bench/README.md)。
|
|
237
|
+
|
|
238
|
+
## 许可证
|
|
239
|
+
|
|
240
|
+
MIT。部分代码改编自 pixel-art-fixer、PixelOE、proper-pixel-art 和 tensorhead/dithering(见 [NOTICE.md](NOTICE.md))。示例图均为 CC0(见 [bench/corpus/CREDITS.md](bench/corpus/CREDITS.md))。
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PixelBuffer } from "./base.ts";
|
|
2
|
+
import type { PixelArtAnalysis, PixelArtAnalysisOptions } from "./types.ts";
|
|
3
|
+
export declare function analyzePixelArt(image: PixelBuffer, options?: PixelArtAnalysisOptions): PixelArtAnalysis;
|
|
4
|
+
/**
|
|
5
|
+
* Async analyze for product import-worker. Same metrics/classification as analyzePixelArt;
|
|
6
|
+
* Auto grid uses detectWithAlgorithmAsync (WASM||proposers Promise overlap).
|
|
7
|
+
*/
|
|
8
|
+
export declare function analyzePixelArtAsync(image: PixelBuffer, options?: PixelArtAnalysisOptions): Promise<PixelArtAnalysis>;
|