feat: remove background
This commit is contained in:
@@ -12,6 +12,7 @@ npm run build:css:watch # Watch mode for CSS
|
||||
npm run preview # Serve HTML at localhost:3000
|
||||
npm run dev # CSS watch + preview server (concurrent)
|
||||
npm run pdf -- <file> # Convert HTML file to PDF
|
||||
npm run remove-bg -- <file|dir> # Remove white background from PNG icons
|
||||
```
|
||||
|
||||
Generate images via Banatie API:
|
||||
@@ -30,6 +31,7 @@ src/
|
||||
scripts/
|
||||
generate-pdf.mjs — HTML → PDF via Puppeteer
|
||||
banatie.mjs — Banatie API client for image generation
|
||||
remove-bg.mjs — Remove white background from PNGs (flood fill)
|
||||
tasks/ — JSON task definition files
|
||||
assets/
|
||||
hero-images/ — spaceship1-6.jpeg (header hero images)
|
||||
@@ -154,6 +156,20 @@ REST API for generating images.
|
||||
|
||||
Configuration is in `src/scripts/banatie.mjs`. Set the `BANATIE_API_KEY` environment variable for authentication.
|
||||
|
||||
## Background Removal
|
||||
|
||||
Script `src/scripts/remove-bg.mjs` removes white backgrounds from PNG icons using flood-fill from edges (like magic wand in Photoshop). Uses sharp. White areas inside objects are preserved.
|
||||
|
||||
```bash
|
||||
node src/scripts/remove-bg.mjs <file|dir> [--threshold N] [--fuzz N]
|
||||
```
|
||||
|
||||
- `--threshold` — whiteness threshold for R,G,B (default: 230, lower = more aggressive)
|
||||
- `--fuzz` — anti-alias radius in pixels at the boundary (default: 0)
|
||||
- Default input: `assets/icons/pack2/`
|
||||
|
||||
This is optional — not all icons need it. After generating/splitting new icons, ask the user if they want background removal on specific files.
|
||||
|
||||
## PDF Generation
|
||||
|
||||
Puppeteer settings for A4 worksheets:
|
||||
|
||||
Reference in New Issue
Block a user