Compare commits

...
6 Commits
Author SHA1 Message Date
ketle-manandClaude Sonnet 4.6 71ed9788a6 release: v0.3.62 — Send GenUI Image ボタン追加・tagger_settings.json バグ修正
- Gallery タブツールバーに Send GenUI Image ボタンを追加(Image Edit ボタン右隣)
  選択画像を ComfyUI へアップロードし GenerateUI Input Image スロット 0 に自動適用
- tagger_settings.json がデータエクスポート対象から漏れていたバグを修正
- ヘルプ helpGallery17 を EN/JA/ZH で追加
- README: v0.3.62 Changelog・スクリーンショット(Tagger/Image Edit)追加
- DEVLOG 更新・pyproject.toml バージョン 0.3.62 に更新

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-27 18:10:47 +09:00
ketle-manandClaude Sonnet 4.6 4cfc793c76 docs: Send GenUI Image ボタンのヘルプを追加(helpGallery17)
- templates/index.html: wfm-help-gallery-17 エントリ追加
- static/js/i18n.js: helpGallery17 キー追加(EN/JA/ZH)
- static/js/app.js: helpIdMap に wfm-help-gallery-17 → helpGallery17 追加

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-27 17:54:06 +09:00
ketle-manandClaude Sonnet 4.6 a7b5667a50 feat: ギャラリータブに Send GenUI Image ボタンを追加
ギャラリーツールバーの Image Edit ボタン右隣に「Send GenUI Image」ボタンを
設置。選択中の画像をギャラリーから取得し、ComfyUI にアップロードした後、
GenerateUI タブの Input > Image スロット 0 へ自動的に適用する。

- templates/index.html: Send GenUI Image ボタン追加
- static/js/comfyui-editor.js: comfyEditor.applyImageToSlot() メソッド追加
- static/js/gallery-tab.js: comfyUI/comfyEditor をインポート、ボタンハンドラ追加
- static/js/i18n.js: galleryNoLoadImageNode / gallerySentGenUI キー追加(EN/JA/ZH)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-27 17:49:14 +09:00
ketle-manandClaude Sonnet 4.6 1eaf4b2158 fix: tagger_settings.json をデータエクスポート/インポート対象に追加
settings_routes.py の _DATA_FILES リストから tagger_settings.json が
漏れており、データバックアップ時にTagger設定が含まれなかった。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-27 17:36:29 +09:00
ketle-manandClaude Sonnet 4.6 cbf35e8ddf feat: v0.3.61 — G'MIC バグ修正・セキュリティ・Draw/Mask ブラシ操作性改善
- G'MIC-Qt 引数順序修正 (-o output input が正しい順序)
- CREATE_NEW_CONSOLE フラグ追加(Windows GUI 表示に必須)
- G'MIC 設定パスのプレースホルダーを汎用パスに変更
- handle_result パストラバーサル対策(gmic_temp 外を 403 拒否)
- ヘルプ追加: G'MIC Filter 使い方・インストール手順(EN/JA/ZH)
- Draw/Mask ブラシカーソルを円形オーバーレイに変更(ブラシサイズ連動)
- キャンバス余白からのドラッグ開始対応(ie-canvas-wrap.mousedown)
- キャンバス外へのストローク継続対応(window mousemove/mouseup 追跡)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-27 16:43:07 +09:00
ketle-man b985f73d35 v0.3.60: Image Edit Filter Tool - G'MIC-Qt integration
Implement G'MIC-Qt filter tool in the Image Edit tab:
- Add gmic_routes.py (new): /api/wfm/gmic/open, /status/{id}, /result endpoints
- Register gmic_routes in wfm.py
- Enable Filter button in index.html (remove ie-tool-placeholder)
- Implement _gmicOpenGui, _gmicWaitForJob, _gmicApplyResult, _gmicAbort in image-edit-tab.js
- Add G'MIC-Qt path setting UI and save logic to settings-tab.js
2026-06-27 14:51:58 +09:00
15 changed files with 852 additions and 17 deletions
+200
View File
@@ -1,5 +1,205 @@
# DEVLOG - ComfyUI-Workflow-Studio
## 2026-06-27: v0.3.62 — Send GenUI Image ボタン追加・tagger_settings.json バグ修正・README 更新
**変更ファイル**: `static/js/gallery-tab.js`, `static/js/comfyui-editor.js`, `static/js/i18n.js`, `static/js/app.js`, `templates/index.html`, `py/routes/settings_routes.py`, `README.md`
### 概要
ギャラリータブのツールバーに **Send GenUI Image** ボタンを追加。選択画像を GenerateUI タブの Input → Image スロット 0 へ自動適用できるようになった。データエクスポートのバグ修正(tagger_settings.json 漏れ)も同梱。
---
### Send GenUI Image ボタン(Gallery タブ)
#### 実装内容
- `templates/index.html` — ギャラリーツールバーの Image Edit ボタン右隣に `#wfm-gallery-send-genui-image-btn` を追加
- `static/js/comfyui-editor.js` — `comfyEditor.applyImageToSlot(file, slotIndex)` メソッドを追加:
- `comfyUI.currentAnalysis.load_image_nodes[slotIndex]` でターゲットノードを特定
- `comfyUI.uploadImage()` で ComfyUI input フォルダへアップロード
- `currentWorkflow[node.id].inputs.image` を更新してワークフローへ即時反映
- GenerateUI の Input > Image スロット UI(プレビュー・ファイル名・ステータス)を即時更新
- `static/js/gallery-tab.js` — ボタンクリックハンドラを追加:
- 選択画像の blob を fetch → File オブジェクト化
- DOM クリックチェーン(main tab → subtab → inner tab)で GenerateUI Input Image タブへ自動遷移
- `comfyEditor.applyImageToSlot(file, 0)` 呼び出し後にサクセストーストを表示
- `static/js/i18n.js` — `galleryNoLoadImageNode` / `gallerySentGenUI` / `helpGallery17` を EN/JA/ZH で追加
- `static/js/app.js` — `helpIdMap` に `"wfm-help-gallery-17": "helpGallery17"` を追加
- `templates/index.html` — ヘルプ `#wfm-help-gallery-17` を追加
#### 動作条件
- ワークフローが GenerateUI に読み込まれており、LoadImage ノードが 1 つ以上存在すること
- 画像が Gallery で選択されていること
---
### データ管理バグ修正 — tagger_settings.json をエクスポート対象に追加
- `py/routes/settings_routes.py` の `_DATA_FILES` リストに `"tagger_settings.json"` を追加
- Tagger のカスタムモデルディレクトリ・閾値設定がエクスポート/インポートされない問題を修正
- `tagger.db`(SQLite)と `wildcard/`(ディレクトリ)は JSON バンドル非対応のため除外継続
---
## 2026-06-27: データ管理バグ修正 — tagger_settings.json をエクスポート対象に追加
**変更ファイル**: `py/routes/settings_routes.py`
### 概要
設定タブのデータエクスポート/インポート機能(`_DATA_FILES`リスト)に `tagger_settings.json` が漏れていたバグを修正。
`config.py` で定義されている全JSONデータファイルと `_DATA_FILES` を照合したところ、Taggerの設定ファイル(カスタムモデルディレクトリ・タグ閾値など)がバックアップ対象から除外されていた。`settings_routes.py` の `_DATA_FILES` リストに `"tagger_settings.json"` を追加して修正。
`tagger.db`(SQLite)と `wildcard/`(ディレクトリ)はJSONバンドルに含められないため除外のまま。
---
## 2026-06-27: v0.3.61 — G'MIC バグ修正・セキュリティ・Draw/Mask ブラシ操作性改善
**変更ファイル**: `py/routes/gmic_routes.py`, `static/js/image-edit-tab.js`, `static/js/image-edit/DrawTool.js`, `static/js/image-edit/MaskTool.js`, `static/js/settings-tab.js`, `static/js/i18n.js`, `static/js/app.js`, `templates/index.html`
### 概要
v0.3.60 で実装した G'MIC-Qt 連携の動作修正・セキュリティ強化と、Draw / Mask ツールのブラシ操作性を大幅に改善した。
---
### G'MIC バグ修正
#### 引数順序の修正
`gmic_qt.exe` の起動引数を正しい順序 `-o <output> <input>` に修正。以前の順序(`<input> -o <output>`)では G'MIC-Qt Standalone が即時終了してGUIが開かなかった。
#### `CREATE_NEW_CONSOLE` フラグ追加
Windows でバックグラウンドプロセス(ComfyUI)からGUIウィンドウを表示するために必須のフラグ。一度削除したが eagle_comic_creater_web の参考実装を確認して再追加した。
#### 設定パスのプレースホルダー修正
`settings-tab.js` の G'MIC-Qt パス入力フィールドのデフォルト値とプレースホルダーからユーザー固有のパス(`statsu-11`)を削除し、汎用的な `C:\path\to\gmic_qt.exe` に変更。`gmic_routes.py` のフォールバック値も同様に空文字に変更。
---
### セキュリティ修正
#### `handle_result` パストラバーサル対策
`POST /api/wfm/gmic/result` の `result_path` は以前リクエストボディから直接 `open()` に渡していた。`Path.resolve().relative_to(gmic_temp)` による検証を追加し、`gmic_temp` ディレクトリ外のパスは 403 を返すように変更。eagle_comic_creater_web の同等実装と同じパターン。
---
### ヘルプ更新(3点セット)
`templates/index.html` / `static/js/i18n.js`(EN/JA/ZH)/ `static/js/app.js`(helpIdMap)を同時更新。
追加したヘルプカード(Mask Tool カードの直後):
| カード | 内容 |
|---|---|
| **G'MIC Filter** | Edit with G'MIC ボタンの使い方、OKから「filter output」ウィンドウを閉じるまでのフロー |
| **G'MIC-Qt Installation** | `gmic.eu/download.html` からのダウンロード手順、解凍先、設定タブへのパス設定方法 |
---
### Draw / Mask ツール改善
#### ブラシカーソルを円に変更
- `DrawTool.activate()` / `MaskTool.activate()` のカーソルを `"crosshair"` → `"none"` に変更
- `image-edit-tab.js` に `_initBrushCursor()` / `_updateBrushCursor(e)` / `_hideBrushCursor()` を追加
- `<body>` に固定配置の `#ie-brush-cursor` div を動的生成(白枠 + 黒シャドウで背景色に依存しない表示)
- `window.mousemove` でキャンバスの `getBoundingClientRect().width / canvas.width` を用いてブラシサイズ(canvas 座標)を CSS px に変換し、円サイズを毎フレーム更新
- ツール切り替え・mouseleave 時に非表示
#### キャンバス外からのドラッグ開始
`ie-canvas-wrap`(キャンバスを囲む余白エリア)の `mousedown` に draw / mask 用の処理を追加。`e.target` が `drawCanvas` / `overlayCanvas` の場合は既存ハンドラに委譲し、余白部分のクリックは `DrawTool.getCanvasPos(drawCanvas, e)` でキャンバス相対座標に変換して描画を開始。
#### キャンバス外でのストローク継続
- `window.mousemove` に draw / mask の描画継続ロジックを追加(`_drawing` フラグが true の間はキャンバス外でも `_onToolMouseMove` を呼ぶ)
- `window.mouseup` に描画終了ロジックを追加(キャンバス外でボタンを離した場合も正常終了)
- `_onToolMouseLeave()` から draw / mask の `onMouseLeave()` 呼び出しを削除(`mouseleave` で描画が中断されなくなった)
---
## 2026-06-27: v0.3.60 — Image Edit Filter Tool (G'MIC-Qt 連携) 実装
**変更ファイル**: `py/routes/gmic_routes.py`(新規), `py/wfm.py`, `templates/index.html`, `static/js/image-edit-tab.js`, `static/js/settings-tab.js`
### 概要
Image Edit タブの「★ Filter」ツール(これまで非アクティブ)に G'MIC-Qt GUI 連携機能を実装。アクティブレイヤーの画像を G'MIC-Qt で開き、フィルター適用後の結果をレイヤーに反映できる。処理中は進行状況を表示し、Undo/Redo にも対応。
---
### バックエンド
#### `py/routes/gmic_routes.py`(新規)
G'MIC-Qt 連携用の API ルートを新規作成。
| エンドポイント | 概要 |
|---|---|
| `POST /api/wfm/gmic/open` | base64 画像を受け取り一時 PNG に保存→ `gmic_qt.exe -o <out> <in>` をバックグラウンドスレッドで起動。`job_id` を返す |
| `GET /api/wfm/gmic/status/{job_id}` | ジョブの進行状況(`pending` / `processing` / `completed` / `failed`)を返す |
| `POST /api/wfm/gmic/result` | `result_path` を受け取り、処理済み画像を base64 エンコードして返す |
- G'MIC-Qt の実行パスは Settings に保存された `gmic_qt_path` を参照。未設定の場合はデフォルトパス `C:\Users\statsu-11\gmic-3.6.5-qt-win64\gmic_qt.exe` にフォールバック。
- プロセスは `subprocess.Popen` + `CREATE_NEW_CONSOLE` でノンブロッキングに起動し、スレッド内でポーリングして完了を検出。
#### `py/wfm.py`
`gmic_routes` を import し、`gmic_routes.setup_routes(app)` をルート登録リストに追加。
---
### フロントエンド
#### `templates/index.html`
左サイドバーの「★ Filter」ボタンから `ie-tool-placeholder` クラスを削除し、クリック可能な通常ボタンに変更。
#### `static/js/image-edit-tab.js`
- `TOOL_DEFS` の `filter` を `ready: false` → `ready: true` に変更
- コンストラクタに `this._gmicState`(`lastResultJobId` / `processing` / `aborted`)を追加
- `_setActiveTool("filter")` → 他ツールへ切り替えた際に `_gmicAbort()` を呼ぶ
- `_renderToolOptions("filter")` — 以下の UI を生成:
- **「G'MIC GUI で編集」ボタン** — 処理中は disabled
- **「結果を反映」ボタン** — 処理完了後に有効化
- **進行状況テキスト** — サーバーからのステータスメッセージを表示
- **「中断」ボタン** — 赤色。クリックでポーリングを停止し UI をリセット
| 新規メソッド | 概要 |
|---|---|
| `_gmicOpenGui()` | アクティブレイヤーを PNG (base64) に変換→ `/api/wfm/gmic/open` で起動 |
| `_gmicWaitForJob(jobId)` | 2 秒間隔でステータスをポーリング(最大 10 分)。完了で「結果を反映」を有効化 |
| `_gmicApplyResult()` | `result_path` 経由で処理済み画像を取得→ `_saveUndo()` → アクティブレイヤーに上書き描画 |
| `_gmicAbort()` | `_gmicState.aborted = true` でポーリングを中断し UI をリセット |
#### `static/js/settings-tab.js`
Settings タブに「**G'MIC-Qt Integration**」セクション(`<details>`)を追加。
- G'MIC-Qt 実行ファイルパス入力フィールド(`id="wfm-settings-gmic-path"`)と「Save」ボタン
- Save クリックで `saveServerSettings({ gmic_qt_path: path })` を呼び出し `settings.json` に永続化
- 保存結果を下部ステータステキストで通知
---
### 使用フロー
1. Settings タブ → 「G'MIC-Qt Integration」セクションで `gmic_qt.exe` のパスを設定・保存
2. Image Edit タブで画像をロードし、左サイドバーの「**★ Filter**」ツールを選択
3. 上部ツールオプションバーの「**G'MIC GUI で編集**」をクリック
4. G'MIC-Qt ウィンドウが起動し、アクティブレイヤーの画像が表示される
5. フィルターを選択し「OK」をクリック
6. WFS が完了を検出し「**結果を反映**」ボタンが有効化される
7. 「結果を反映」をクリックするとアクティブレイヤーに処理済み画像が適用される
8. **Ctrl+Z** でフィルター適用前の状態に戻すことも可能
---
## 2026-06-27: v0.3.59 — Image Edit Mask Tool 実装・Draw/Mask 描画バグ修正・クリッピング保存対応
**変更ファイル**: `static/js/image-edit-tab.js`, `static/js/image-edit/MaskTool.js`, `static/js/image-edit/DrawTool.js`, `static/js/image-edit/LayerManager.js`, `templates/index.html`, `static/css/image-edit-tab.css`, `static/js/i18n.js`, `static/js/app.js`
+31 -5
View File
@@ -18,7 +18,7 @@ A comprehensive workflow, asset management, and generation UI plugin for [ComfyU
- Built-in AI tools (translation and more)
![Workflow Studio](https://img.shields.io/badge/ComfyUI-Custom_Node-blue)
![Version](https://img.shields.io/badge/version-0.3.59-green)
![Version](https://img.shields.io/badge/version-0.3.62-green)
## Screenshots
@@ -42,6 +42,10 @@ A comprehensive workflow, asset management, and generation UI plugin for [ComfyU
|:---:|:---:|
| ![WS Library](docs/6_ws_library.png) | ![Library Information](docs/7_library_Infomation.png) |
| Tagger Tab | Image Edit Tab |
|:---:|:---:|
| ![Tagger Tab](docs/12_Tagger.png) | ![Image Edit Tab](docs/13_ImageEdit.png) |
| Customize | |
|:---:|:---:|
| ![Customize](docs/8_Customize.png) | |
@@ -146,6 +150,7 @@ Two independent modes selectable via **[Image Loop] / [Gallery]** toggle buttons
- **Text Size** — one slider (10–28 px) adjusts font size for all prompt and chat textareas at once: Generate UI positive/negative prompts, AI Assistant chat input, Preset prompts, Wildcard prompt and file editor, and Metadata prompt full preview; takes effect immediately and saved with Save Settings
- **RAW JSON Colors** — customize the 6 syntax highlight colors for the Raw JSON editor in Generate UI: Default Text (base), Name/Scheduler (yellow), Title (pink), Width/Height (green), Prompt/Text (cyan), Image/File (red); changes apply immediately on color pick; Reset Defaults restores the original scheme; saved to `localStorage` under `wfm_settings.jsonColors` and applied on startup
- **Wildcard Integration** — link the WFS wildcard directory to ComfyUI-Impact-Pack's `wildcards/` directory (directory junction on Windows, symlink on other OS); existing WFS wildcard files are automatically migrated; requires [ComfyUI-Impact-Pack](https://github.com/ltdrdata/ComfyUI-Impact-Pack)
- **G'MIC-Qt Integration** — set the path to `gmic_qt.exe` for the Image Edit Filter tool; download G'MIC-Qt Standalone from `gmic.eu/download.html` (Windows: `gmic_qt-win64.zip`), extract anywhere, then enter the full path to `gmic_qt.exe` and click Save
- **Language** — English / Japanese / Chinese
### Gallery Tab (v0.3.44)
@@ -164,6 +169,8 @@ Two independent modes selectable via **[Image Loop] / [Gallery]** toggle buttons
- **Detail panel** — view filename, path, tags, groups, and metadata in a slide-out panel
- **Workflow viewer** — Metadata tab displays workflow JSON from PNG embedded data (`prompt` / `workflow` keys) or from workflow saved by the Generate UI tab; **Copy & Send Canvas** button copies the JSON to the clipboard and sends the workflow directly to the ComfyUI canvas (UI and API formats both supported)
- **Load GenUI button** — loads the embedded ComfyUI workflow from the selected image directly into the GenerateUI tab; shows a warning toast if no workflow is embedded or the format is unsupported; Metadata button is styled green, Load GenUI button uses the primary accent color
- **Image Edit button** — toolbar button; sends the selected image directly to the Image Edit tab as the base layer
- **Send GenUI Image button** — toolbar button (next to Image Edit); uploads the selected image to ComfyUI and sets it as the input for the first LoadImage node in the GenerateUI tab; automatically switches to GenerateUI → Input → Image; requires a workflow with at least one LoadImage node to be loaded
- **Workflow auto-save** — images generated from the Generate UI tab have their workflow automatically saved to gallery metadata
- **Output folder configurable** — set the scanned output folder from Settings tab
- **Performance** — server-side 256px JPEG thumbnail generation with disk cache (`data/thumb_cache/`); infinite-scroll paging (50 images per page, IntersectionObserver); folder-level mtime cache (60s TTL); bulk operations use single-request API endpoints
@@ -209,18 +216,19 @@ Two independent modes selectable via **[Image Loop] / [Gallery]** toggle buttons
- **DB tab** — searchable SQLite database of all tagged images; click a row to open the edit panel and modify WD Tags / VLM Tags; Save updates the record, Delete removes it; Export CSV downloads all records
- **Dependencies** — install into ComfyUI's embedded Python: `python_embedded\python.exe -m pip install -r requirements.txt`; for GPU inference use `onnxruntime-gpu`; TensorFlow (DeepDanbooru) is optional and commented out in `requirements.txt`
### Image Edit Tab (v0.3.59)
### Image Edit Tab (v0.3.61)
- **Layer-based image editor** — compose images with multiple layers (Image, Text, Draw, Mask types) and export the composite as PNG
- **Loading images** — drag & drop onto the canvas, Upload button, or send from the Gallery tab via the **Image Edit** toolbar button; first image becomes Layer 1 (auto-locked), subsequent images are added as new layers scaled to fit the canvas
- **New button** — create a blank canvas with custom dimensions (WxH prompt); clears all existing layers
- **Tools** — Select (V), Draw (B), Text (T), Shape (S), Mask (🎭), Blur (≈), BG Remove (⬚); tool options bar updates per active tool
- **Tools** — Select (V), Draw (B), Text (T), Shape (S), Mask (🎭), Blur (≈), BG Remove (⬚), Filter (★); tool options bar updates per active tool
- **Select** — click to select; drag to move; drag corner handles to resize; drag circle handle to rotate; Flip H / Flip V / Rotate angle in the options bar; double-click a text layer to re-edit its content
- **Draw** — freehand brush; options: color, brush size, blend mode; paints directly onto the active draw layer while all other layers remain visible
- **Draw** — freehand brush; options: color, brush size, blend mode; paints directly onto the active draw layer while all other layers remain visible; brush cursor shown as a size-accurate circle; strokes can start from outside the canvas margin and continue past the edge
- **Text** — click to place; configure font, size, bold/italic, align, and color; placed as an exact-size text layer sized to the measured bounding box; double-click to re-edit
- **Shape** — drag to draw geometric shapes (Rect / Ellipse / Line / FreeLine); options: shape type, Rounded toggle (Rect/Ellipse), Fill color, Stroke color + width, Opacity; each committed shape becomes an independent draw layer; Stroke None hidden for Line/FreeLine (stroke always active)
- **Mask** — paint a white mask onto a dedicated mask layer; click **M** in the Layers header to add a mask layer (Mask tool activates automatically); clicking a mask layer in the list also switches to the Mask tool; **Tool Options bar**: Paint sub-tool button, Invert checkbox, Overlay color picker (default red), Blur slider (0–50 px); **Properties pane** (left of the Layers panel): Size (1–200 px), Hardness (0–100%), Mode — **Add** (draw white = mask present) / **Erase** (erase to transparent = mask absent); **✂ button** on the layer row enables/disables the mask as a clipping mask — when enabled (blue), the layer directly below is clipped to the painted area and the result is applied when exporting
- **Mask** — paint a white mask onto a dedicated mask layer; click **M** in the Layers header to add a mask layer (Mask tool activates automatically); clicking a mask layer in the list also switches to the Mask tool; **Tool Options bar**: Paint sub-tool button, Invert checkbox, Overlay color picker (default red), Blur slider (0–50 px); **Properties pane** (left of the Layers panel): Size (1–200 px), Hardness (0–100%), Mode — **Add** (draw white = mask present) / **Erase** (erase to transparent = mask absent); **✂ button** on the layer row enables/disables the mask as a clipping mask — when enabled (blue), the layer directly below is clipped to the painted area and the result is applied when exporting; brush cursor shown as a size-accurate circle; strokes can start from outside the canvas margin and continue past the edge
- **Blur** — **Whole Blur**: Gaussian blur to the entire active layer with intensity slider (1–50 px); **Whole Mosaic**: pixelation mosaic with block-size slider (5–100 px); **Rect Blur / Rect Mosaic**: enable the toggle then drag a rectangle on the canvas to apply blur or mosaic to that region only (blue preview for blur, orange for mosaic); Rect Blur and Rect Mosaic are mutually exclusive; all operations support Undo
- **BG Remove** — remove the background from the active layer; **Lightweight (@imgly)**: runs entirely in the browser via CDN (no server required; ~40 MB model downloaded on first use); **BiRefNet**: high-quality removal via the Python backend (coming soon); **New Layer** option (default on) adds the result as a new layer above the original; when off, replaces the active layer in-place
- **Filter (G'MIC)** — apply G'MIC-Qt filter effects to the active image layer; click **Edit with G'MIC** to launch G'MIC-Qt GUI; select a filter and click OK — a "G'MIC-Qt filter output" window appears; close it to save the result back as the active layer; requires G'MIC-Qt Standalone installed and path configured in Settings → G'MIC-Qt Executable Path
- **Layer panel** — layer list with visibility (👁/🚫), lock (🔒/🔓), and clipping-mask (✂) toggles; opacity slider; type icons (🖼 image / T text / ✏ draw / ⬚ mask); Layer 1 is automatically locked on first image load
- **Layer lock** — locked layers show an orange bounding box and 🔒 icon on the canvas; move/resize/rotate are disabled while locked; click the 🔓 button in the layer row to unlock
- **Text quality** — text layers are rendered at their measured bounding-box size; resizing with the Select tool regenerates the canvas at the new display resolution so text stays sharp
@@ -354,6 +362,24 @@ Click the **camera icon** (next to the W button) in ComfyUI's top bar to capture
## Changelog
### v0.3.62
- **Gallery tab — Send GenUI Image button** — new toolbar button (next to Image Edit); uploads the selected image to ComfyUI and sets it as the input for the first LoadImage node in the GenerateUI tab; automatically switches to GenerateUI → Input → Image; `comfyEditor.applyImageToSlot(file, slotIndex)` added to `comfyui-editor.js` for reusable image-slot injection
- **Bug fix: tagger_settings.json missing from data export** — `tagger_settings.json` was absent from `_DATA_FILES` in `settings_routes.py`; Tagger model directory and threshold settings were silently excluded from Settings → Data Management export/import; fixed by adding the file to the export list
- **Help — Send GenUI Image** — new help card (`helpGallery17`) added in EN/JA/ZH; registered in `helpIdMap`
- **Screenshots — Tagger and Image Edit tabs** — `docs/12_Tagger.png` and `docs/13_ImageEdit.png` added to the README screenshots section
### v0.3.61
- **Image Edit — Draw / Mask brush cursor** — cursor replaced with a size-accurate circle overlay matching the current brush size; the circle scales correctly with canvas zoom so the visible area matches exactly what will be painted
- **Image Edit — Draw / Mask out-of-canvas strokes** — strokes can now start from the canvas margin area (outside the image boundary) and continue past the edge without interruption; `window`-level `mousemove` / `mouseup` tracking keeps the stroke alive when the pointer leaves the canvas element
- **G'MIC — argument order fix** — corrected `gmic_qt.exe` launch arguments to `-o <output> <input>` (the only order G'MIC-Qt Standalone accepts); the previous order caused the GUI to exit immediately without opening
- **G'MIC — settings path placeholder** — replaced the hard-coded user-specific default path with a generic `C:\path\to\gmic_qt.exe` placeholder; settings load without a pre-filled path for new users
- **G'MIC — security: path traversal fix** — `POST /api/wfm/gmic/result` now validates that `result_path` is inside the `gmic_temp` directory before reading the file; requests for paths outside that directory are rejected with 403
- **Help — G'MIC Filter section** — added two new help cards (G'MIC Filter usage and G'MIC-Qt Installation) with full i18n support (English / Japanese / Chinese)
### v0.3.60
- **Image Edit — Filter tool (G'MIC-Qt integration)** — the previously inactive ★ Filter tool now launches G'MIC-Qt GUI with the active layer image; select a filter and click OK, then close the "G'MIC-Qt filter output" window to apply the result back as the active layer; polling-based job system with progress display, Cancel button, and Undo support; requires G'MIC-Qt Standalone (`gmic_qt.exe`) configured in Settings
- **Settings — G'MIC-Qt Executable Path** — new collapsible section in Settings for entering and saving the path to `gmic_qt.exe`
### v0.3.59
- **Image Edit — Mask Tool** — new Mask tool (🎭) in the Image Edit sidebar; click **M** in the Layers header to add a mask layer (Mask tool activates automatically); clicking a mask layer in the layer list also switches to the Mask tool; **Tool Options bar**: Paint button, Invert checkbox (inverts overlay preview), Overlay color picker (default red), Blur slider (0–50 px) for overlay edge softening; **Properties pane** (left of the Layers panel, shown when Mask tool is active): Size (1–200 px), Hardness (0–100%), Mode — **Add** / **Erase** toggle buttons (active mode highlighted in blue)
- **Image Edit — Clipping mask (✂ button)** — each mask layer row shows a ✂ toggle; when enabled (blue), the mask clips the layer directly below it so only the painted area is visible; clipping is applied to PNG save / Save to Gallery / Send to ComfyUI exports
+183
View File
@@ -0,0 +1,183 @@
"""G'MIC-Qt integration API routes."""
import asyncio
import base64
import datetime
import json
import logging
import mimetypes
import os
import subprocess
import threading
import uuid
from pathlib import Path
from aiohttp import web
from ..services.settings_service import SettingsService
from ..config import DATA_DIR
logger = logging.getLogger(__name__)
_settings = SettingsService()
# Global job store
# key: job_id, value: dict {status, message, result_path, error}
_gmic_jobs = {}
_gmic_jobs_lock = threading.Lock()
def _gmic_run_gui(job_id: str, input_path: str, output_path: str, gmic_exe: str):
"""Run gmic_qt.exe in a background process/thread and wait for completion.
G'MIC-Qt Standalone argument order: -o <output> <input>
After OK the "filter output" window appears; closing it saves to output_path.
"""
args = [gmic_exe, "-o", output_path, input_path]
logger.info("[gmic] Launching: %s", " ".join(args))
try:
with _gmic_jobs_lock:
_gmic_jobs[job_id]["status"] = "processing"
_gmic_jobs[job_id]["message"] = "G'MIC GUIで編集中..."
import time
kwargs = {}
if os.name == "nt":
# Required on Windows to show the GUI window from a background process
kwargs["creationflags"] = subprocess.CREATE_NEW_CONSOLE
proc = subprocess.Popen(args, **kwargs)
proc.wait()
time.sleep(0.5)
if os.path.exists(output_path) and os.path.getsize(output_path) > 0:
with _gmic_jobs_lock:
_gmic_jobs[job_id]["status"] = "completed"
_gmic_jobs[job_id]["result_path"] = output_path
_gmic_jobs[job_id]["message"] = "完了"
logger.info("[gmic] Result saved: %s", output_path)
else:
raise ValueError("G'MIC GUIがキャンセルされました")
except Exception as e:
with _gmic_jobs_lock:
_gmic_jobs[job_id]["status"] = "failed"
_gmic_jobs[job_id]["error"] = str(e)
_gmic_jobs[job_id]["message"] = f"エラー: {str(e)}"
logger.error("[gmic] Error: %s", e)
def setup_routes(app: web.Application):
"""Register G'MIC API routes."""
app.router.add_post("/api/wfm/gmic/open", handle_open)
app.router.add_get("/api/wfm/gmic/status/{job_id}", handle_status)
app.router.add_post("/api/wfm/gmic/result", handle_result)
async def handle_open(request: web.Request) -> web.Response:
"""POST /api/wfm/gmic/open - Open image in G'MIC GUI."""
try:
body = await request.json()
image_b64 = body.get("image_b64", "")
if not image_b64:
return web.json_response({"error": "image_b64 field is required"}, status=400)
# Retrieve setting for gmic path
data = _settings.load()
gmic_exe = data.get("gmic_qt_path", "")
if not os.path.exists(gmic_exe):
return web.json_response({
"error": f"G'MIC executable not found at: {gmic_exe}. Please configure the path in settings."
}, status=400)
ext = ".png"
if image_b64.startswith("data:"):
header, image_b64 = image_b64.split(",", 1)
mime = header.split(";")[0].split(":")[1]
guessed = mimetypes.guess_extension(mime)
if guessed:
ext = ".jpg" if guessed == ".jpe" else guessed
img_bytes = base64.b64decode(image_b64)
temp_dir = Path(DATA_DIR) / "gmic_temp"
temp_dir.mkdir(parents=True, exist_ok=True)
now_str = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
input_path = str(temp_dir / f"gmic_input_{now_str}{ext}")
output_path = str(temp_dir / f"gmic_output_{now_str}_{str(uuid.uuid4())[:8]}{ext}")
with open(input_path, "wb") as f:
f.write(img_bytes)
job_id = str(uuid.uuid4())
with _gmic_jobs_lock:
_gmic_jobs[job_id] = {
"status": "pending",
"message": "G'MIC GUIを起動中...",
"result_path": None,
"error": None,
}
# Start G'MIC thread
t = threading.Thread(
target=_gmic_run_gui,
args=(job_id, input_path, output_path, gmic_exe),
daemon=True,
)
t.start()
return web.json_response({"job_id": job_id, "status": "pending", "message": "起動中"})
except Exception as e:
logger.error("[gmic] open error: %s", e)
return web.json_response({"error": str(e)}, status=500)
async def handle_status(request: web.Request) -> web.Response:
"""GET /api/wfm/gmic/status/{job_id} - Check job status."""
try:
job_id = request.match_info.get("job_id", "")
with _gmic_jobs_lock:
job = _gmic_jobs.get(job_id)
if job is None:
return web.json_response({"error": "Job not found"}, status=404)
return web.json_response({
"job_id": job_id,
"status": job["status"],
"message": job.get("message", ""),
"result_path": job.get("result_path"),
"error": job.get("error"),
})
except Exception as e:
logger.error("[gmic] status error: %s", e)
return web.json_response({"error": str(e)}, status=500)
async def handle_result(request: web.Request) -> web.Response:
"""POST /api/wfm/gmic/result - Get result image base64."""
try:
body = await request.json()
result_path = body.get("result_path", "")
if not result_path or not os.path.exists(result_path):
return web.json_response({"error": f"Result file not found: {result_path}"}, status=404)
# Path traversal guard: only allow files inside gmic_temp
allowed_dir = (Path(DATA_DIR) / "gmic_temp").resolve()
try:
Path(result_path).resolve().relative_to(allowed_dir)
except ValueError:
return web.json_response({"error": "Access denied: path outside gmic_temp"}, status=403)
with open(result_path, "rb") as f:
img_bytes = f.read()
ext = os.path.splitext(result_path)[1].lower()
mime_map = {
".png": "image/png",
".jpg": "image/jpeg",
".jpeg": "image/jpeg",
".webp": "image/webp",
".bmp": "image/bmp",
".tiff": "image/tiff"
}
mime = mime_map.get(ext, "image/png")
b64 = base64.b64encode(img_bytes).decode("ascii")
return web.json_response({"image_b64": f"data:{mime};base64,{b64}"})
except Exception as e:
logger.error("[gmic] result error: %s", e)
return web.json_response({"error": str(e)}, status=500)
+1
View File
@@ -23,6 +23,7 @@ _DATA_FILES = [
"prompts.json",
"model_metadata.json",
"gallery_metadata.json",
"tagger_settings.json",
]
+2 -1
View File
@@ -61,7 +61,7 @@ class WorkflowStudio:
app.router.add_get("/wfm", serve_index_page)
# API routes
from .routes import workflow_routes, settings_routes, ollama_routes, eagle_routes, nodes_routes, prompts_routes, models_routes, gallery_routes, wildcard_routes, tagger_routes
from .routes import workflow_routes, settings_routes, ollama_routes, eagle_routes, nodes_routes, prompts_routes, models_routes, gallery_routes, wildcard_routes, tagger_routes, gmic_routes
workflow_routes.setup_routes(app)
settings_routes.setup_routes(app)
@@ -73,5 +73,6 @@ class WorkflowStudio:
gallery_routes.setup_routes(app)
wildcard_routes.setup_routes(app)
tagger_routes.setup_routes(app)
gmic_routes.setup_routes(app)
logger.info("Workflow Studio: Routes registered successfully")
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui-workflow-studio"
description = "A comprehensive workflow, asset management, and generation UI plugin for ComfyUI. Manage workflows, models, images, and prompts; batch generation and Image Feeder in the GenerateUI tab; library side panel with canvas drag & drop and AI tools."
version = "0.3.59"
version = "0.3.62"
license = "MIT"
requires-python = ">= 3.10"
dependencies = ["jinja2"]
+8
View File
@@ -400,6 +400,7 @@ function applyI18nToHtml() {
"wfm-help-gallery-11": "helpGallery11", "wfm-help-gallery-12": "helpGallery12",
"wfm-help-gallery-13": "helpGallery13", "wfm-help-gallery-14": "helpGallery14",
"wfm-help-gallery-15": "helpGallery15", "wfm-help-gallery-16": "helpGallery16",
"wfm-help-gallery-17": "helpGallery17",
"wfm-help-tagger-title": "helpTaggerTitle",
"wfm-help-tagger-1": "helpTagger1", "wfm-help-tagger-2": "helpTagger2",
"wfm-help-tagger-3": "helpTagger3", "wfm-help-tagger-4": "helpTagger4",
@@ -456,6 +457,13 @@ function applyI18nToHtml() {
"wfm-help-imageedit-mask-1": "helpImageEditMask1", "wfm-help-imageedit-mask-2": "helpImageEditMask2",
"wfm-help-imageedit-mask-3": "helpImageEditMask3", "wfm-help-imageedit-mask-4": "helpImageEditMask4",
"wfm-help-imageedit-mask-5": "helpImageEditMask5",
"wfm-help-imageedit-gmic-title": "helpImageEditGmicTitle",
"wfm-help-imageedit-gmic-1": "helpImageEditGmic1", "wfm-help-imageedit-gmic-2": "helpImageEditGmic2",
"wfm-help-imageedit-gmic-3": "helpImageEditGmic3", "wfm-help-imageedit-gmic-4": "helpImageEditGmic4",
"wfm-help-imageedit-gmic-install-title": "helpImageEditGmicInstallTitle",
"wfm-help-imageedit-gmic-install-1": "helpImageEditGmicInstall1",
"wfm-help-imageedit-gmic-install-2": "helpImageEditGmicInstall2",
"wfm-help-imageedit-gmic-install-3": "helpImageEditGmicInstall3",
"wfm-help-imageedit-tabkbd-title": "helpImageEditTabKbdTitle",
"wfm-help-imageedit-tabkbd-1": "helpImageEdit22", "wfm-help-imageedit-tabkbd-2": "helpImageEdit23",
"wfm-help-imageedit-tabkbd-3": "helpImageEdit24", "wfm-help-imageedit-tabkbd-4": "helpImageEdit25",
+30
View File
@@ -1131,6 +1131,36 @@ export const comfyEditor = {
});
},
async applyImageToSlot(file, slotIndex = 0) {
const loadNodes = comfyUI.currentAnalysis?.load_image_nodes || [];
const node = loadNodes[slotIndex];
if (!node) throw new Error("No LoadImage node at slot " + slotIndex);
const result = await comfyUI.uploadImage(file, file.name);
if (!result.name) throw new Error("Upload returned no filename");
if (comfyUI.currentWorkflow?.[node.id]) {
comfyUI.currentWorkflow[node.id].inputs.image = result.name;
}
const previewWrap = document.getElementById(`wfm-i2i-preview-wrap-${slotIndex}`);
const previewImg = document.getElementById(`wfm-i2i-preview-${slotIndex}`);
const filenameEl = document.getElementById(`wfm-i2i-filename-${slotIndex}`);
const statusEl = document.getElementById(`wfm-i2i-status-${slotIndex}`);
const applyBtn = document.querySelector(`.wfm-i2i-apply[data-slot="${slotIndex}"]`);
if (previewImg) {
previewImg.src = `/view?filename=${encodeURIComponent(result.name)}&type=input`;
if (previewWrap) previewWrap.style.display = "";
}
if (filenameEl) filenameEl.textContent = result.name;
if (statusEl) { statusEl.textContent = `✓ ${result.name}`; statusEl.style.color = "var(--wfm-success)"; }
if (applyBtn) applyBtn.disabled = true;
_syncRawJson();
return result.name;
},
syncToWorkflow() {
// Sync prompt texts before generation
const posSelect = document.getElementById("wfm-prompt-pos-target");
+35
View File
@@ -9,6 +9,8 @@ import { loadFileIntoMetadataTab } from "./metadata-tab.js";
import { loadWorkflowIntoEditor } from "./generate-tab.js";
import { escapeHtml } from "./util.js";
import { comfyWorkflow } from "./comfyui-workflow.js";
import { comfyUI } from "./comfyui-client.js";
import { comfyEditor } from "./comfyui-editor.js";
// ── 定数 ─────────────────────────────────────────────────────
@@ -1471,6 +1473,39 @@ function bindEvents() {
}
});
// 選択画像を GenerateUI Image タブへ送信
document.getElementById("wfm-gallery-send-genui-image-btn")?.addEventListener("click", async () => {
if (!state.selectedImage) {
showToast(t("gallerySelectImageFirst"), "info");
return;
}
if (!comfyUI.currentAnalysis) {
showToast(t("noWorkflowLoaded"), "info");
return;
}
const loadNodes = comfyUI.currentAnalysis.load_image_nodes || [];
if (loadNodes.length === 0) {
showToast(t("galleryNoLoadImageNode"), "info");
return;
}
try {
const res = await fetch(API.serveImage(state.selectedImage.path));
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const blob = await res.blob();
const file = new File([blob], state.selectedImage.filename, { type: blob.type || "image/png" });
// GenerateUI → Input subtab → Image inner tab へ切り替え
document.querySelector('[data-tab="generate"]')?.click();
document.querySelector('.wfm-gen-subtab-btn[data-subtab="input"]')?.click();
document.querySelector('.wfm-input-inner-tab[data-input-tab="image"]')?.click();
await comfyEditor.applyImageToSlot(file, 0);
showToast(t("gallerySentGenUI"), "success");
} catch (e) {
showToast(t("errorWithMsg", e.message), "error");
}
});
// 検索
document.getElementById("wfm-gallery-search")?.addEventListener("input", (e) => {
state.search = e.target.value;
+36
View File
@@ -468,6 +468,8 @@ const LANGUAGES = {
galleryOutputDirLabel: "Output Folder Path",
galleryOutputDirHint: "Set the ComfyUI output folder to browse in the Gallery tab. Leave blank to use ComfyUI's default output directory.",
gallerySelectImageFirst: "Please select an image first",
galleryNoLoadImageNode: "No LoadImage node in current workflow",
gallerySentGenUI: "Sent to GenerateUI Image tab",
galleryNoEmbeddedWorkflow: "No ComfyUI workflow embedded in this image.",
galleryBulkSelected: "selected",
galleryBulkDeselectAll: "Deselect All",
@@ -696,6 +698,7 @@ const LANGUAGES = {
helpGallery14: "Tagger button (purple, in the detail panel action row): opens the selected image directly in the Tagger tab's Single mode for instant tagging",
helpGallery15: "F button (cyan overlay, top-left of each thumbnail): toggle the image in/out of the __Feeder__ group with a single click; cyan and always visible when in group, visible on hover only when not; quickly queue images for the Feeder tab Gallery mode",
helpGallery16: "Image Edit button (toolbar, next to Refresh): sends the currently selected image to the Image Edit tab; if layers already exist the image is added as a new layer scaled to fit the canvas, otherwise it becomes Layer 1",
helpGallery17: "Send GenUI Image button (toolbar, next to Image Edit): uploads the selected image to ComfyUI and sets it as the input for the first LoadImage node in the GenerateUI tab; automatically switches to GenerateUI → Input → Image; requires a workflow with at least one LoadImage node to be loaded first",
// -- Tagger Tab --
helpTaggerTitle: "Tagger Tab",
@@ -794,6 +797,15 @@ const LANGUAGES = {
helpImageEditBgRemove3: "New Layer (checked by default): the result is added as a new layer above the active layer at the same position and display size — the original layer is preserved",
helpImageEditBgRemove4: "When New Layer is unchecked, the active layer's canvas is replaced in-place with the background-removed result",
helpImageEditBgRemove5: "Click Remove BG to start processing; status text shows Loading model → Processing → Done; supports Undo (Ctrl+Z)",
helpImageEditGmicTitle: "G'MIC Filter (Edit with G'MIC)",
helpImageEditGmic1: "Applies G'MIC-Qt filter effects to the active image layer; the result is loaded back as a new layer",
helpImageEditGmic2: "Click \"Edit with G'MIC\" in the toolbar to launch G'MIC-Qt GUI with the current layer image",
helpImageEditGmic3: "In G'MIC-Qt: choose a filter, adjust parameters, then click OK — a \"G'MIC-Qt filter output\" window appears; close it to save and return the result to the Image Edit tab",
helpImageEditGmic4: "Requires G'MIC-Qt Standalone to be installed and its path configured in Settings → G'MIC-Qt Executable Path; only image-type layers are supported",
helpImageEditGmicInstallTitle: "G'MIC-Qt Installation",
helpImageEditGmicInstall1: "Download G'MIC-Qt Standalone from gmic.eu/download.html — choose the \"G'MIC-Qt\" package for your OS (Windows: gmic_qt-win64.zip)",
helpImageEditGmicInstall2: "Extract the zip to any folder (e.g. C:\\tools\\gmic); no installer required",
helpImageEditGmicInstall3: "Open Settings → G'MIC-Qt Executable Path, enter the full path to gmic_qt.exe (e.g. C:\\tools\\gmic\\gmic_qt.exe), then click Save",
helpImageEditTabKbdTitle: "Image Edit Tab Shortcuts",
helpShortcutsTitle: "Keyboard Shortcuts",
helpShortcuts1: "Escape: Close modal/panel",
@@ -1413,6 +1425,8 @@ const LANGUAGES = {
galleryOutputDirLabel: "Outputフォルダのパス",
galleryOutputDirHint: "ギャラリータブで参照するComfyUIのoutputフォルダを設定します。空欄の場合はComfyUIのデフォルトoutputディレクトリを使用します。",
gallerySelectImageFirst: "先に画像を選択してください",
galleryNoLoadImageNode: "現在のワークフローにLoadImageノードがありません",
gallerySentGenUI: "GenerateUI Imageタブへ送信しました",
galleryNoEmbeddedWorkflow: "この画像にはComfyUIワークフローが埋め込まれていません。",
galleryBulkSelected: "件選択中",
galleryBulkDeselectAll: "選択解除",
@@ -1641,6 +1655,7 @@ const LANGUAGES = {
helpGallery14: "Taggerボタン(紫、詳細パネルのアクション行):選択画像をTaggerタブのSingleモードで直接開き、即座にタグ付けを開始できる",
helpGallery15: "Fボタン(シアン色オーバーレイ、各サムネイル左上):クリック一つで画像を __Feeder__ グループに追加/削除;グループ内の場合は常にシアン色で表示、非グループ時はホバー時のみ表示;FeederタブのGalleryモードへ素早く画像を追加できる",
helpGallery16: "Image Editボタン(ツールバー、Refreshボタン横):選択中の画像をImage Editタブに送信;既にレイヤーが存在する場合はキャンバスに合わせてスケールして新規レイヤーとして追加、存在しない場合はLayer 1になる",
helpGallery17: "Send GenUI Imageボタン(ツールバー、Image Editボタン横):選択画像をComfyUIにアップロードし、GenerateUIタブの最初のLoadImageノードへ入力として設定;GenerateUI → Input → Imageへ自動切り替え;事前にLoadImageノードを含むワークフローの読み込みが必要",
// -- Tagger Tab --
helpTaggerTitle: "Taggerタブ",
@@ -1738,6 +1753,15 @@ const LANGUAGES = {
helpImageEditBgRemove3: "New Layer(デフォルトON):結果をアクティブレイヤーの上に同じ位置・表示サイズの新規レイヤーとして追加 — 元レイヤーは保持",
helpImageEditBgRemove4: "New LayerをOFFにすると、アクティブレイヤーのキャンバスが背景除去済みの結果で直接置き換えられる",
helpImageEditBgRemove5: "Remove BGをクリックして処理開始;ステータステキストに「Loading model → Processing → Done」と表示;Undo(Ctrl+Z)に対応",
helpImageEditGmicTitle: "G'MIC フィルター(G'MICで編集)",
helpImageEditGmic1: "アクティブな画像レイヤーにG'MIC-Qtのフィルター効果を適用する;処理結果は新規レイヤーとして読み込まれる",
helpImageEditGmic2: "ツールバーの「G'MICで編集」ボタンをクリックすると、現在のレイヤー画像でG'MIC-Qt GUIを起動する",
helpImageEditGmic3: "G'MIC-Qt上でフィルターを選択してパラメーターを調整後にOKをクリック —「G'MIC-Qt filter output」ウィンドウが表示されるので閉じると結果がImage Editタブに反映される",
helpImageEditGmic4: "G'MIC-Qt Standaloneがインストールされ、設定タブの「G'MIC-Qt Executable Path」にパスが設定されている必要がある;画像タイプのレイヤーのみ対応",
helpImageEditGmicInstallTitle: "G'MIC-Qt のインストール",
helpImageEditGmicInstall1: "gmic.eu/download.html から G'MIC-Qt Standalone をダウンロード — OS に合ったパッケージを選択(Windows: gmic_qt-win64.zip)",
helpImageEditGmicInstall2: "zipを任意のフォルダに解凍する(例: C:\\tools\\gmic);インストーラー不要",
helpImageEditGmicInstall3: "設定タブ → G'MIC-Qt Executable Path に gmic_qt.exe のフルパスを入力(例: C:\\tools\\gmic\\gmic_qt.exe)して Save をクリック",
helpImageEditTabKbdTitle: "Image Edit タブのショートカット",
helpShortcutsTitle: "キーボード操作",
helpShortcuts1: "Escape:モーダル・パネルを閉じる",
@@ -2357,6 +2381,8 @@ const LANGUAGES = {
galleryOutputDirLabel: "输出文件夹路径",
galleryOutputDirHint: "设置图库标签页浏览的ComfyUI输出文件夹。留空则使用ComfyUI默认输出目录。",
gallerySelectImageFirst: "请先选择图像",
galleryNoLoadImageNode: "当前工作流中没有LoadImage节点",
gallerySentGenUI: "已发送至GenerateUI图像标签",
galleryNoEmbeddedWorkflow: "此图像中未嵌入ComfyUI工作流。",
galleryBulkSelected: "项已选择",
galleryBulkDeselectAll: "取消全选",
@@ -2585,6 +2611,7 @@ const LANGUAGES = {
helpGallery14: "Tagger按钮(紫色,位于详情面板操作行):将所选图像直接在Tagger标签的Single模式中打开,即可立即进行标注",
helpGallery15: "F按钮(青色悬浮按钮,每个缩略图左上角):单击即可将图像添加到/从__Feeder__组中移除;图像在组中时始终显示青色,不在组中时仅悬停时可见;可快速为Feeder标签Gallery模式添加队列图像",
helpGallery16: "Image Edit按钮(工具栏,Refresh按钮旁):将当前选中的图像发送到Image Edit标签;如果已有图层则按比例缩放添加为新图层,否则将成为Layer 1",
helpGallery17: "Send GenUI Image按钮(工具栏,Image Edit按钮旁):将选中图像上传至ComfyUI并设置为GenerateUI标签中第一个LoadImage节点的输入;自动切换至GenerateUI → Input → Image;需要预先加载包含至少一个LoadImage节点的工作流",
// -- Tagger Tab --
helpTaggerTitle: "Tagger标签",
@@ -2682,6 +2709,15 @@ const LANGUAGES = {
helpImageEditBgRemove3: "New Layer(默认勾选):结果作为新图层添加到活动图层上方,位置和显示尺寸相同 — 原始图层保留",
helpImageEditBgRemove4: "取消勾选New Layer时,活动图层的画布将被去除背景的结果直接替换",
helpImageEditBgRemove5: "点击Remove BG开始处理;状态文字显示「Loading model → Processing → Done」;支持撤销(Ctrl+Z)",
helpImageEditGmicTitle: "G'MIC 滤镜(用G'MIC编辑)",
helpImageEditGmic1: "对活动图像图层应用G'MIC-Qt滤镜效果;处理结果将作为新图层加载",
helpImageEditGmic2: "点击工具栏中的「用G'MIC编辑」按钮,以当前图层图像启动G'MIC-Qt GUI",
helpImageEditGmic3: "在G'MIC-Qt中选择滤镜并调整参数后点击OK — 将显示「G'MIC-Qt filter output」窗口;关闭该窗口后结果将反映到Image Edit选项卡",
helpImageEditGmic4: "需要安装G'MIC-Qt Standalone并在设置的「G'MIC-Qt Executable Path」中配置路径;仅支持图像类型图层",
helpImageEditGmicInstallTitle: "G'MIC-Qt 安装方法",
helpImageEditGmicInstall1: "从 gmic.eu/download.html 下载G'MIC-Qt Standalone — 选择适合您操作系统的包(Windows: gmic_qt-win64.zip)",
helpImageEditGmicInstall2: "将zip解压到任意文件夹(如 C:\\tools\\gmic);无需安装程序",
helpImageEditGmicInstall3: "打开设置 → G'MIC-Qt Executable Path,输入 gmic_qt.exe 的完整路径(如 C:\\tools\\gmic\\gmic_qt.exe),点击 Save",
helpImageEditTabKbdTitle: "图像编辑选项卡快捷键",
helpShortcutsTitle: "键盘操作",
helpShortcuts1: "Escape:关闭弹窗/面板",
+261 -7
View File
@@ -19,7 +19,7 @@ const TOOL_DEFS = [
{ id: "shape", icon: "□", label: "Shape", ready: true },
{ id: "mask", icon: "🎭", label: "Mask", ready: true },
{ id: "blur", icon: "≈", label: "Blur", ready: true },
{ id: "filter", icon: "★", label: "Filter", ready: false },
{ id: "filter", icon: "★", label: "Filter", ready: true },
{ id: "bgremove", icon: "⬚", label: "BG Remove", ready: true },
];
@@ -81,6 +81,12 @@ class ImageEditTab {
this._maskInverted = false;
this._maskOverlayColor = "#ff0000";
this._maskBlur = 0;
// G'MIC tool state
this._gmicState = {
lastResultJobId: null,
processing: false,
aborted: false
};
}
// ── 初期化 ────────────────────────────────────
@@ -93,6 +99,52 @@ class ImageEditTab {
this._setupCanvasEvents();
this._setupLayerPanel();
this._setupKeyboard();
this._initBrushCursor();
}
// ── ブラシカーソル ────────────────────────────
_initBrushCursor() {
const el = document.createElement("div");
el.id = "ie-brush-cursor";
Object.assign(el.style, {
position: "fixed",
pointerEvents: "none",
border: "1.5px solid rgba(255,255,255,0.85)",
boxShadow: "0 0 0 1px rgba(0,0,0,0.6)",
borderRadius: "50%",
display: "none",
transform: "translate(-50%,-50%)",
zIndex: "99999",
});
document.body.appendChild(el);
this._brushCursorEl = el;
}
_updateBrushCursor(e) {
const el = this._brushCursorEl;
if (!el) return;
const tool = this._activeTool;
const size = tool === "draw"
? this._drawTool?.brushSize
: tool === "mask" ? this._maskTool?.brushSize : null;
if (size == null) { el.style.display = "none"; return; }
const refCanvas = document.getElementById("ie-canvas-draw");
if (!refCanvas) { el.style.display = "none"; return; }
const rect = refCanvas.getBoundingClientRect();
const scale = rect.width / refCanvas.width;
const px = Math.max(2, size * scale);
el.style.width = px + "px";
el.style.height = px + "px";
el.style.left = e.clientX + "px";
el.style.top = e.clientY + "px";
el.style.display = "block";
}
_hideBrushCursor() {
if (this._brushCursorEl) this._brushCursorEl.style.display = "none";
}
// ── ツールボタン ──────────────────────────────
@@ -108,11 +160,15 @@ class ImageEditTab {
}
_setActiveTool(toolId) {
this._hideBrushCursor();
if (this._activeTool === "draw") this._drawTool?.deactivate();
if (this._activeTool === "text") this._textTool?.deactivate();
if (this._activeTool === "select") this._selectTool?.deactivate();
if (this._activeTool === "shape") this._shapeTool?.deactivate();
if (this._activeTool === "mask") this._maskTool?.deactivate();
if (this._activeTool === "filter") {
this._gmicAbort();
}
if (this._activeTool === "blur") {
this._blurRectMode = null;
this._blurDragging = false;
@@ -539,6 +595,24 @@ class ImageEditTab {
`;
document.getElementById("ie-bgremove-btn")?.addEventListener("click", () => this._applyBgRemove());
} else if (toolId === "filter") {
const openBtnDisabled = this._gmicState.processing ? "disabled" : "";
const applyBtnDisabled = (!this._gmicState.lastResultJobId || this._gmicState.processing) ? "disabled" : "";
const progressStyle = this._gmicState.processing ? "display:flex" : "display:none";
el.innerHTML = `
<div class="ie-opt-group">
<button class="wfm-btn wfm-btn-sm wfm-btn-primary" id="ie-gmic-open-btn" ${openBtnDisabled}>G'MIC GUIで編集</button>
<button class="wfm-btn wfm-btn-sm" id="ie-gmic-apply-btn" ${applyBtnDisabled}>結果を反映</button>
</div>
<div class="ie-opt-group" id="ie-gmic-progress-area" style="${progressStyle}; align-items:center; gap:6px;">
<span id="ie-gmic-progress-lbl" style="font-size:11px; color:var(--wfm-text-secondary);">G'MIC GUIを起動中...</span>
<button class="wfm-btn wfm-btn-sm" id="ie-gmic-abort-btn" style="background:#ea4335;color:#fff;">中断</button>
</div>
`;
document.getElementById("ie-gmic-open-btn")?.addEventListener("click", () => this._gmicOpenGui());
document.getElementById("ie-gmic-apply-btn")?.addEventListener("click", () => this._gmicApplyResult());
document.getElementById("ie-gmic-abort-btn")?.addEventListener("click", () => this._gmicAbort());
} else {
const def = TOOL_DEFS.find(d => d.id === toolId);
el.innerHTML = `<span style="font-size:12px;color:var(--wfm-text-secondary);">${def?.label ?? toolId}: coming soon</span>`;
@@ -675,19 +749,49 @@ class ImageEditTab {
this._panning = true;
this._panStart = { x: e.clientX - this._panOffset.x, y: e.clientY - this._panOffset.y };
wrap.style.cursor = "grabbing";
return;
}
// Draw/Mask: allow starting a stroke from the canvas margin area
if (e.button !== 0) return;
const tool = this._activeTool;
if (tool !== "draw" && tool !== "mask") return;
const drawCanvas = document.getElementById("ie-canvas-draw");
const overlayCanvas = document.getElementById("ie-canvas-overlay");
// Skip if the event target is already a canvas — existing handlers cover that
if (e.target === drawCanvas || e.target === overlayCanvas) return;
if (!this._layerMgr || !drawCanvas) return;
this._onToolMouseDown(e, drawCanvas);
});
window.addEventListener("mousemove", e => {
if (!this._panning) return;
this._panOffset.x = e.clientX - this._panStart.x;
this._panOffset.y = e.clientY - this._panStart.y;
this._applyTransform();
if (this._panning) {
this._panOffset.x = e.clientX - this._panStart.x;
this._panOffset.y = e.clientY - this._panStart.y;
this._applyTransform();
}
// Draw/Mask: update brush cursor and continue stroke outside canvas
const tool = this._activeTool;
if (tool === "draw" || tool === "mask") {
this._updateBrushCursor(e);
const isDrawing = tool === "draw"
? this._drawTool?._drawing
: this._maskTool?._drawing;
if (isDrawing) {
const refCanvas = document.getElementById("ie-canvas-draw");
if (refCanvas) this._onToolMouseMove(e, refCanvas);
}
}
});
window.addEventListener("mouseup", e => {
if (this._panning && (e.button === 1 || e.button === 0)) {
this._panning = false;
wrap.style.cursor = this._spaceDown ? "grab" : "";
}
// Draw/Mask: end stroke from anywhere (including outside canvas)
if (e.button === 0) {
const tool = this._activeTool;
if (tool === "draw" && this._drawTool?._drawing) this._drawTool.onMouseUp();
if (tool === "mask" && this._maskTool?._drawing) this._maskTool.onMouseUp();
}
});
// draw / text 用 mousedown
@@ -791,8 +895,8 @@ class ImageEditTab {
}
_onToolMouseLeave() {
if (this._activeTool === "draw") this._drawTool?.onMouseLeave();
if (this._activeTool === "mask") this._maskTool?.onMouseLeave();
// Draw/Mask: do NOT stop the stroke — window mousemove/mouseup continue tracking
this._hideBrushCursor();
if (this._activeTool === "shape") this._shapeTool?.onMouseLeave();
if (this._activeTool === "select") this._selectTool?.onMouseLeave();
if (this._activeTool === "blur" && this._blurDragging) {
@@ -1748,6 +1852,156 @@ class ImageEditTab {
if (btn) btn.disabled = false;
}
}
// ── G'MIC Integration ──────────────────────────
async _gmicOpenGui() {
if (!this._layerMgr) { showToast("No image loaded", "error"); return; }
const layer = this._layerMgr.activeLayer;
if (!layer) { showToast("No active layer", "error"); return; }
this._syncActiveLayerFromCanvas();
if (this._gmicState.processing) return;
const dataUrl = layer.canvas.toDataURL("image/png");
this._gmicState.processing = true;
const openBtn = document.getElementById("ie-gmic-open-btn");
const progressArea = document.getElementById("ie-gmic-progress-area");
const progressLbl = document.getElementById("ie-gmic-progress-lbl");
const applyBtn = document.getElementById("ie-gmic-apply-btn");
if (openBtn) openBtn.disabled = true;
if (applyBtn) applyBtn.disabled = true;
if (progressArea) progressArea.style.display = "flex";
if (progressLbl) progressLbl.textContent = "画像をサーバーへ送信中...";
try {
const res = await fetch("/api/wfm/gmic/open", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ image_b64: dataUrl })
});
if (!res.ok) {
const err = await res.json().catch(() => ({}));
throw new Error(err.error || `HTTP ${res.status}`);
}
const data = await res.json();
this._gmicState.lastResultJobId = data.job_id;
if (progressLbl) progressLbl.textContent = "G'MIC GUIで編集中... フィルターを選択して「OK」を押すと適用可能になります";
await this._gmicWaitForJob(data.job_id);
} catch (e) {
if (e.message !== "__aborted__") {
showToast("G'MIC Error: " + e.message, "error");
}
this._gmicState.processing = false;
this._gmicState.aborted = false;
if (openBtn) openBtn.disabled = false;
if (progressArea) progressArea.style.display = "none";
}
}
_gmicAbort() {
this._gmicState.aborted = true;
this._gmicState.processing = false;
const openBtn = document.getElementById("ie-gmic-open-btn");
const progressArea = document.getElementById("ie-gmic-progress-area");
if (progressArea) progressArea.style.display = "none";
if (openBtn) openBtn.disabled = false;
}
async _gmicWaitForJob(jobId) {
const progressLbl = document.getElementById("ie-gmic-progress-lbl");
const applyBtn = document.getElementById("ie-gmic-apply-btn");
const maxWait = 600, interval = 2000;
const start = Date.now();
this._gmicState.aborted = false;
while (true) {
if (this._gmicState.aborted) throw new Error("__aborted__");
if ((Date.now() - start) / 1000 > maxWait) throw new Error("Timeout");
await new Promise(r => setTimeout(r, interval));
if (this._gmicState.aborted) throw new Error("__aborted__");
try {
const res = await fetch(`/api/wfm/gmic/status/${jobId}`);
if (res.status === 404) throw new Error("__aborted__");
if (!res.ok) continue;
const status = await res.json();
if (status.status === "completed") {
this._gmicState.lastResultJobId = jobId;
if (applyBtn) applyBtn.disabled = false;
if (progressLbl) progressLbl.textContent = "処理完了 → 「結果を反映」で画像に適用";
this._gmicState.processing = false;
showToast("G'MIC filtering complete. Click Apply to insert result.", "success");
return;
}
if (status.status === "failed") {
if (progressLbl) progressLbl.textContent = status.error || "G'MIC GUIがキャンセルされました";
throw new Error("__aborted__");
}
if (progressLbl) progressLbl.textContent = status.message || "G'MIC GUIで編集中...";
} catch (e) {
if (e.message === "__aborted__" || e.message.includes("Timeout")) throw e;
}
}
}
async _gmicApplyResult() {
if (!this._gmicState.lastResultJobId) {
showToast("No G'MIC result to apply", "error");
return;
}
const applyBtn = document.getElementById("ie-gmic-apply-btn");
const openBtn = document.getElementById("ie-gmic-open-btn");
const progressArea = document.getElementById("ie-gmic-progress-area");
if (applyBtn) applyBtn.disabled = true;
try {
const statusRes = await fetch(`/api/wfm/gmic/status/${this._gmicState.lastResultJobId}`);
if (!statusRes.ok) throw new Error(`HTTP ${statusRes.status}`);
const statusData = await statusRes.json();
if (!statusData.result_path) throw new Error("No result path found");
const b64res = await fetch("/api/wfm/gmic/result", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ result_path: statusData.result_path })
});
if (!b64res.ok) throw new Error(`HTTP ${b64res.status}`);
const { image_b64: dataUrl } = await b64res.json();
const img = await new Promise((resolve, reject) => {
const i = new Image();
i.onload = () => resolve(i);
i.onerror = () => reject(new Error("Failed to load result image"));
i.src = dataUrl;
});
this._saveUndo();
const layer = this._layerMgr.activeLayer;
if (!layer) throw new Error("No active layer");
layer.canvas.width = img.width;
layer.canvas.height = img.height;
layer.ctx = layer.canvas.getContext("2d");
layer.ctx.drawImage(img, 0, 0);
this._updateCompositeView();
this._refreshLayerList();
showToast("G'MIC filter applied successfully", "success");
// Reset G'MIC status
this._gmicState.lastResultJobId = null;
this._gmicState.processing = false;
if (openBtn) openBtn.disabled = false;
if (progressArea) progressArea.style.display = "none";
this._renderToolOptions("filter");
} catch (err) {
showToast("Failed to apply G'MIC result: " + err.message, "error");
if (applyBtn) applyBtn.disabled = false;
}
}
}
export const imageEditTab = new ImageEditTab();
+1 -1
View File
@@ -36,7 +36,7 @@ export class DrawTool {
onChange(fn) { this._onChange = fn; }
activate() {
if (this.canvas) this.canvas.style.cursor = "crosshair";
if (this.canvas) this.canvas.style.cursor = "none";
}
deactivate() {
+1 -1
View File
@@ -34,7 +34,7 @@ export class MaskTool {
onChange(fn) { this._onChange = fn; }
activate() {
if (this.canvas) this.canvas.style.cursor = "crosshair";
if (this.canvas) this.canvas.style.cursor = "none";
}
deactivate() {
+42
View File
@@ -738,6 +738,24 @@ export async function initSettingsTab() {
</div>
</details>
<!-- G'MIC Integration -->
<details class="wfm-settings-section">
<summary class="wfm-settings-summary">G'MIC-Qt Integration</summary>
<div class="wfm-form-group">
<label>G'MIC-Qt Executable Path</label>
<div style="display:flex;gap:8px;">
<input type="text" class="wfm-input" id="wfm-settings-gmic-path"
value="${serverSettings.gmic_qt_path || ""}"
placeholder="C:\\path\\to\\gmic_qt.exe"
style="flex:1;">
<button class="wfm-btn wfm-btn-primary wfm-btn-sm" id="wfm-settings-gmic-path-save">
Save
</button>
</div>
<div id="wfm-settings-gmic-path-status" style="font-size:12px;margin-top:4px;"></div>
</div>
</details>
<!-- Data Management -->
<details class="wfm-settings-section">
<summary class="wfm-settings-summary">${t("dataManagement")}</summary>
@@ -1415,4 +1433,28 @@ export async function initSettingsTab() {
// Reset file input so same file can be re-selected
e.target.value = "";
});
// Save G'MIC path setting
document.getElementById("wfm-settings-gmic-path-save")?.addEventListener("click", async () => {
const path = document.getElementById("wfm-settings-gmic-path")?.value.trim() || "";
const statusEl = document.getElementById("wfm-settings-gmic-path-status");
if (statusEl) {
statusEl.textContent = "Saving...";
statusEl.style.color = "var(--wfm-text-secondary)";
}
try {
await saveServerSettings({ gmic_qt_path: path });
serverSettings.gmic_qt_path = path;
showToast("G'MIC path saved successfully", "success");
if (statusEl) {
statusEl.textContent = "Saved successfully!";
statusEl.style.color = "var(--wfm-success)";
}
} catch (err) {
if (statusEl) {
statusEl.textContent = "Error: " + err.message;
statusEl.style.color = "var(--wfm-danger)";
}
}
});
}
+20 -1
View File
@@ -1196,6 +1196,7 @@
<li id="wfm-help-gallery-13"><b>Load GenUI</b> button (blue, in the detail panel tab bar): loads the embedded ComfyUI workflow from the selected image directly into the GenerateUI tab and switches to it; shows a warning toast if no workflow is embedded or the format is not supported</li>
<li id="wfm-help-gallery-14"><b>Tagger</b> button (purple, in the detail panel action row): opens the selected image directly in the Tagger tab's Single mode for instant tagging</li>
<li id="wfm-help-gallery-16"><b>Image Edit</b> button (toolbar, next to Refresh): sends the currently selected image to the Image Edit tab; if layers already exist the image is added as a new layer scaled to fit the canvas, otherwise it becomes Layer 1</li>
<li id="wfm-help-gallery-17"><b>Send GenUI Image</b> button (toolbar, next to Image Edit): uploads the selected image to ComfyUI and sets it as the input for the first LoadImage node in the GenerateUI tab; automatically switches to GenerateUI → Input → Image; requires a workflow with at least one LoadImage node to be loaded first</li>
</ul>
</div>
</div>
@@ -1340,6 +1341,23 @@
<li id="wfm-help-imageedit-mask-5">✂ button on a mask layer row: toggles the layer as a clipping mask — when enabled (blue), the mask clips the layer directly below it so only the painted area is visible; clipping is applied when saving PNG / Gallery / ComfyUI</li>
</ul>
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-imageedit-gmic-title">G'MIC Filter (Edit with G'MIC)</h3>
<ul>
<li id="wfm-help-imageedit-gmic-1">Applies G'MIC-Qt filter effects to the active image layer; the result is loaded back as a new layer</li>
<li id="wfm-help-imageedit-gmic-2">Click "Edit with G'MIC" in the toolbar to launch G'MIC-Qt GUI with the current layer image</li>
<li id="wfm-help-imageedit-gmic-3">In G'MIC-Qt: choose a filter, adjust parameters, then click OK — a "G'MIC-Qt filter output" window appears; close it to save and return the result to the Image Edit tab</li>
<li id="wfm-help-imageedit-gmic-4">Requires G'MIC-Qt Standalone to be installed and its path configured in Settings → G'MIC-Qt Executable Path; only image-type layers are supported</li>
</ul>
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-imageedit-gmic-install-title">G'MIC-Qt Installation</h3>
<ul>
<li id="wfm-help-imageedit-gmic-install-1">Download G'MIC-Qt Standalone from <strong>gmic.eu/download.html</strong> — choose the "G'MIC-Qt" package for your OS (Windows: gmic_qt-win64.zip)</li>
<li id="wfm-help-imageedit-gmic-install-2">Extract the zip to any folder (e.g. C:\tools\gmic); no installer required</li>
<li id="wfm-help-imageedit-gmic-install-3">Open Settings → G'MIC-Qt Executable Path, enter the full path to gmic_qt.exe (e.g. C:\tools\gmic\gmic_qt.exe), then click Save</li>
</ul>
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-imageedit-text-title">Text Object Quality</h3>
<ul>
@@ -1469,6 +1487,7 @@
<span id="wfm-gallery-count" class="wfm-nodes-count"></span>
<button id="wfm-gallery-refresh-btn" class="wfm-btn wfm-btn-sm">Refresh</button>
<button id="wfm-gallery-send-image-edit-btn" class="wfm-btn wfm-btn-sm" title="Send selected image to Image Edit tab">Image Edit</button>
<button id="wfm-gallery-send-genui-image-btn" class="wfm-btn wfm-btn-sm" title="Send selected image to GenerateUI Image input">Send GenUI Image</button>
</div>
<!-- 複数選択時の一括操作バー -->
<div id="wfm-gallery-bulk-bar" class="wfm-gallery-bulk-bar" style="display:none;">
@@ -1591,7 +1610,7 @@
<button class="ie-tool-btn" data-tool="shape" title="Shape (S)">□</button>
<button class="ie-tool-btn" data-tool="mask" title="Mask">🎭</button>
<button class="ie-tool-btn" data-tool="blur" title="Blur">≈</button>
<button class="ie-tool-btn ie-tool-placeholder" data-tool="filter" title="Filter">★</button>
<button class="ie-tool-btn" data-tool="filter" title="Filter">★</button>
<button class="ie-tool-btn" data-tool="bgremove" title="BG Remove">⬚</button>
</div>