facebetter 1.0.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/README.md ADDED
@@ -0,0 +1,167 @@
1
+ # Facebetter
2
+
3
+ Face beauty effects SDK with WebAssembly support. Works in browsers, Node.js, and Electron.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install facebetter
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Browser (`<script>` tag)
14
+
15
+ ```html
16
+ <script src="node_modules/facebetter/dist/facebetter.js"></script>
17
+ <script>
18
+ const { BeautyEffectEngine, EngineConfig } = Facebetter;
19
+
20
+ const config = new EngineConfig({
21
+ appId: 'your-app-id',
22
+ appKey: 'your-app-key'
23
+ });
24
+
25
+ const engine = new BeautyEffectEngine(config);
26
+
27
+ await engine.init();
28
+
29
+ // Process image
30
+ const canvas = document.getElementById('myCanvas');
31
+ const processed = engine.processImage(canvas);
32
+
33
+ // Draw result
34
+ const ctx = canvas.getContext('2d');
35
+ ctx.putImageData(processed, 0, 0);
36
+ </script>
37
+ ```
38
+
39
+ ### Vue / React / Vite / Webpack (ES Module)
40
+
41
+ ```javascript
42
+ import { BeautyEffectEngine, EngineConfig } from 'facebetter';
43
+
44
+ const config = new EngineConfig({
45
+ appId: 'your-app-id',
46
+ appKey: 'your-app-key'
47
+ });
48
+
49
+ const engine = new BeautyEffectEngine(config);
50
+ await engine.init();
51
+
52
+ // Process image
53
+ const canvas = document.getElementById('myCanvas');
54
+ const processed = engine.processImage(canvas);
55
+ ```
56
+
57
+ **Note for Webpack 5**: Add to `webpack.config.js`:
58
+ ```javascript
59
+ experiments: {
60
+ asyncWebAssembly: true
61
+ }
62
+ ```
63
+
64
+ ### Node.js / Electron Main Process
65
+
66
+ ```javascript
67
+ // ESM
68
+ import { BeautyEffectEngine, EngineConfig } from 'facebetter';
69
+
70
+ // Or CommonJS
71
+ const { getFacebetter } = require('facebetter');
72
+ const { BeautyEffectEngine, EngineConfig } = await getFacebetter();
73
+
74
+ const config = new EngineConfig({
75
+ licenseJson: '{"your": "license", "json": "here"}' // Must provide licenseJson in Node.js
76
+ });
77
+
78
+ const engine = new BeautyEffectEngine(config);
79
+ await engine.init();
80
+
81
+ // Process image (use Uint8ClampedArray or Buffer)
82
+ const imageData = new Uint8ClampedArray(width * height * 4);
83
+ const processed = engine.processImage(imageData, width, height);
84
+ ```
85
+
86
+ ## API
87
+
88
+ ### EngineConfig
89
+
90
+ ```javascript
91
+ const config = new EngineConfig({
92
+ appId: 'your-app-id', // Required if licenseJson not provided
93
+ appKey: 'your-app-key', // Required if licenseJson not provided
94
+ licenseJson: '{"..."}' // Optional, if provided appId/appKey not needed
95
+ });
96
+ ```
97
+
98
+ ### BeautyEffectEngine
99
+
100
+ ```javascript
101
+ const engine = new BeautyEffectEngine(config);
102
+
103
+ // Initialize
104
+ await engine.init();
105
+
106
+ // Set beauty parameters
107
+ engine.setBasicParam(BasicParam.Whitening, 0.5);
108
+ engine.setReshapeParam(ReshapeParam.FaceThin, 0.3);
109
+ engine.setMakeupParam(MakeupParam.Lipstick, 0.4);
110
+
111
+ // Process image
112
+ const processed = engine.processImage(inputImage);
113
+
114
+ // Cleanup
115
+ engine.destroy();
116
+ ```
117
+
118
+ ## Constants
119
+
120
+ - `BeautyType`: Basic, Reshape, Makeup, Segmentation
121
+ - `BasicParam`: Smoothing, Sharpening, Whitening, Rosiness
122
+ - `ReshapeParam`: FaceThin, FaceVShape, EyeSize, etc.
123
+ - `MakeupParam`: Lipstick, Blush
124
+ - `BackgroundMode`: None, Blur, Image
125
+ - `ProcessMode`: Image, Video
126
+
127
+ ## Building
128
+
129
+ ### Prerequisites
130
+
131
+ Before building, ensure you have the C++ build artifacts. When using CMake install, WASM files will be automatically installed to `src/engine/web/dist/`. Otherwise, you need to manually place them there:
132
+
133
+ ```
134
+ src/engine/web/dist/
135
+ ├── facebetter_wasm.js # C++ build artifact (must exist before build)
136
+ ├── facebetter_wasm.wasm # C++ build artifact (must exist before build)
137
+ └── facebetter_wasm.data # C++ build artifact (must exist before build)
138
+ ```
139
+
140
+ **Note**: When using `cmake --install`, WASM files are automatically installed to `src/engine/web/dist/`. If building manually, ensure WASM files are in `src/engine/web/dist/` before running `npm run build`.
141
+
142
+ ### Build Steps
143
+
144
+ ```bash
145
+ # 1. Install dependencies
146
+ npm install
147
+
148
+ # 2. Build all formats
149
+ npm run build
150
+
151
+ # 3. Build production version (with minification)
152
+ npm run build:prod
153
+
154
+ # 4. Build development version (with sourcemap)
155
+ npm run build:dev
156
+ ```
157
+
158
+ The build process will:
159
+ 1. Build UMD version (`src/engine/web/dist/facebetter.js`) for browser `<script>` tags
160
+ 2. Build ESM version (`src/engine/web/dist/facebetter.esm.js`) for Vue/React/Vite
161
+
162
+ **Output directory**: All build artifacts are generated in `src/engine/web/dist/` directory, ready for npm publish.
163
+
164
+ ## License
165
+
166
+ MIT
167
+