This commit is contained in:
lovebird 2026-04-16 12:42:59 +02:00
parent a335e388a8
commit 8211d50851
4 changed files with 35 additions and 2 deletions

View File

@ -74,7 +74,7 @@ Registers a **PM-Media** cascading menu on image extensions (including **`.avif`
Under `SystemFileAssociations`, each extension is registered as **`.ext`**, **`.EXT`**, and **`.Ext`** so Explorer picks up the menu regardless of filename casing.
Defaults: **`--media-bin`** = this executable; **`--explorer-script`** / **`--explorer-convert-script`** = `<exe_dir>\\scripts\\explorer-*.ps1`, or `packages/media/scripts\\…` from a dev `cpp\\dist` build.
Defaults: **`--media-bin`** = this executable; **`--explorer-script`** / **`--explorer-convert-script`** / **`--explorer-ui-script`** = `<exe_dir>\\scripts\\explorer-*.ps1`, or `packages/media/scripts\\…` from a dev `cpp\\dist` build.
`pm-media register-explorer` forwards argv to `pm-image.exe` for convenience.
@ -109,7 +109,7 @@ Sharp wraps libvips: **decode → process → encode**. We do the same with `vip
| `flip` / `flop` | `flip` / `flop` | |
| Letterbox | `background` | `#rrggbb` for `contain` |
**Windows:** `pm-image resize --ui` opens a **native Win32** dialog to choose input/output paths, max dimensions, fit mode, quality, and enlargement / autorotate / strip options. Other CLI flags seed the dialog; **`--src` / `--dst` are not allowed** with `--ui`. If you cancel, the command exits without processing.
**Windows:** `pm-image resize --ui` opens a **native Win32** dialog to choose input/output paths, max dimensions, fit mode, quality, and enlargement / autorotate / strip options. Other CLI flags seed the dialog; if you cancel, the command exits without processing. `pm-image resize --ui-next` opens the newer **Win32++ ribbon UI** with drag-drop queue and settings panel; optional `--src` or positional input paths pre-seed the queue.
**REST** `POST /v1/resize` accepts **`application/json`** (same keys as the table, plus **“Batch paths & cache”** below) **or** **`multipart/form-data`** (upload a file; response is the **image bytes** — see **`serve`**). **IPC** uses the same JSON keys as the table, plus the batch/cache fields.
@ -325,6 +325,28 @@ curl -s -X POST http://127.0.0.1:8080/v1/resize \
Optional JSON: `"cache":false`, `"expand_glob":false`, `"cache_dir":"..."` — see **Batch paths & cache** above.
### `transform` — AI image editing
Uses a generative-AI model (currently **Google Gemini**) to edit an image based on a text prompt. Reads the input, sends image + prompt to the API, and writes the result.
```bash
pm-image transform photo.jpg -p "remove the background"
pm-image transform photo.jpg out.png -p "make it black and white" --model gemini-3-pro-image-preview
```
| Flag | Default | Notes |
|------|---------|-------|
| `input` (positional) | **required** | Input image path |
| `output` (positional) | auto from input + prompt | Output path |
| `-p, --prompt` | **required** | Editing prompt |
| `--provider` | `google` | AI provider |
| `--model` | `gemini-3-pro-image-preview` | Model name |
| `--api-key` | env `IMAGE_TRANSFORM_GOOGLE_API_KEY` | API key |
| `--aspect-ratio` | auto | `1:1`, `16:9`, `4:3`, `3:4`, `9:16`, `21:9` |
| `--image-size` | `1K` | `512`, `1K`, `2K`, `4K` |
If `--api-key` is omitted, the value of the **`IMAGE_TRANSFORM_GOOGLE_API_KEY`** environment variable is used.
### `ipc` — one JSON line per connection (TCP; Unix socket on Linux/macOS)
```bash
@ -335,6 +357,14 @@ pm-image ipc --host 127.0.0.1 -p 9333 --cache-dir ./cache/images
Same JSON fields as REST (`input`, `output`, globs, `expand_glob`, `cache`, `cache_dir`, resize options).
### `kbot` — forward to kbot
Forwards remaining arguments to an external **kbot** binary. Set the **`KBOT_EXE`** environment variable to the kbot binary path (e.g. `packages/kbot/cpp/dist/kbot.exe`).
```bash
KBOT_EXE=./kbot.exe pm-image kbot ai --prompt "hello"
```
## Tests
From `packages/media/cpp`, after **`cmake --build --preset release`** (or `npm run build:release`):

Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 KiB

After

Width:  |  Height:  |  Size: 382 KiB

View File

@ -0,0 +1,3 @@
media\cpp\packages\Win32xx\samples\Picture\src
media\cpp\packages\Win32xx\samples\ListView

Binary file not shown.