# ComfyUI → Obsidian Prompt Note Кастомная нода для ComfyUI, которая после генерации **автоматически сохраняет готовое изображение и позитивный промт в отдельную заметку Obsidian**. A ComfyUI custom node that, after each generation, **automatically saves the finished image and the positive prompt into a dedicated Obsidian note**. --- ## 🇷🇺 Русский ### Что делает нода Нода **`Save Image + Obsidian Note`** (категория **Obsidian**) для каждого изображения: 1. Сохраняет PNG в стандартную папку `output` ComfyUI (с обычной нумерацией и вшитыми метаданными workflow — как штатная нода `Save Image`). 2. Копирует этот PNG в папку для заметок (по умолчанию `Comfy-Promt` внутри вашего хранилища Obsidian). 3. Создаёт рядом заметку `.md` **с тем же именем, что у изображения, но без расширения** (например, `ComfyUI_00042_.md`). Внутри: - встроенное изображение `![[ComfyUI_00042_.png]]`; - позитивный промт в **блоке кода** — чтобы его можно было скопировать одним кликом. Пример содержимого заметки: ````markdown ![[ComfyUI_00042_.png]] ``` a cinematic portrait of a fox, golden hour, 85mm, highly detailed ``` ```` ### Установка 1. Скопируйте папку `comfyui-obsidian-promt` в каталог `custom_nodes` вашего ComfyUI. - ComfyUI Desktop / portable: `...\ComfyUI\custom_nodes\` - В этой системе: `C:\Users\dimir\Documents\ComfyUI\custom_nodes\` Либо клонируйте репозиторий прямо туда: ```bash cd C:\Users\dimir\Documents\ComfyUI\custom_nodes git clone http://192.168.1.171:3000/dimon/comfyui-obsidian-promt.git ``` 2. **Настройте путь сохранения** (см. раздел ниже) — иначе заметки будут падать в чужую папку. 3. **Полностью перезапустите ComfyUI.** Нода появится в меню добавления нод в категории **Obsidian** под именем **Save Image + Obsidian Note**. Дополнительные зависимости не нужны: `numpy`, `Pillow` и `folder_paths` уже входят в любую сборку ComfyUI. ### Как использовать Добавьте ноду **Save Image + Obsidian Note** в конец workflow (вместо или рядом со штатной `Save Image`) и подключите `images` к выходу `VAE Decode`. Текст промта нода может получать двумя способами — выбирается переключателем **`prompt_source`**: | Режим | Что подключать | Откуда берётся текст | |-------|----------------|----------------------| | `string` (по умолчанию) | вход `positive_prompt` (тип **STRING**) | строка ровно как вы её ввели | | `conditioning` | вход `positive_conditioning` (тип **CONDITIONING**) | текст прослеживается по графу workflow до ноды `CLIP Text Encode` и читается её поле text | **Режим `string`** — подключите строковую ноду с текстом (например `String`/`Text` из comfyui-custom-scripts или KJNodes). Удобно, если промт формируется динамически (wildcards / dynamic prompts): берите строку уже после раскрытия, тогда в заметку попадёт финальный текст. **Режим `conditioning`** — подключите тот же выход `CLIP Text Encode`, что идёт в `KSampler`. Отдельная строковая нода не нужна. > ⚠️ **Важно про режим `conditioning`.** Из CONDITIONING (это числовые > эмбеддинги) исходный текст восстановить невозможно — кодирование одностороннее. > Поэтому нода идёт по графу workflow назад от подключённого входа до ноды > `CLIP Text Encode` и читает её текстовое поле. Для обычных статических промтов > это точно. Промежуточные ноды (`Conditioning Combine/Concat` и т. п.) > проходятся насквозь, тексты склеиваются. Если же текст подставляется в > `CLIP Text Encode` нестандартным способом (некоторые wildcard-/BNK-ноды), из > графа может прочитаться шаблон или ничего — тогда в заметку попадёт пометка > `[промт не найден: ...]`. В таких случаях используйте режим `string`. Опциональный вход `filename_prefix` (по умолчанию `ComfyUI`) задаёт префикс имени файла — как у штатной `Save Image`. ### Как изменить папку для сохранения Откройте файл `__init__.py` и найдите вверху блок **`НАСТРОЙКА ПУТЕЙ / PATH CONFIGURATION`**. Там две строки: ```python VAULT_DIR = r"C:\Users\dimir\Documents\ObsidianTask" OBSIDIAN_SUBFOLDER = "Comfy-Promt" ``` - **`VAULT_DIR`** — полный путь к хранилищу Obsidian (или к любой другой папке). На Windows используйте префикс `r"..."` и обратные слэши. - **`OBSIDIAN_SUBFOLDER`** — имя подпапки внутри `VAULT_DIR`, куда складываются `.md` и копии `.png`. Папка создаётся автоматически. Чтобы писать прямо в `VAULT_DIR`, поставьте пустую строку `""`. Примеры: ```python VAULT_DIR = r"D:\MyVault" # другой диск VAULT_DIR = r"\\NAS\share\Obsidian" # сетевая папка VAULT_DIR = "/home/user/Obsidian" # Linux / macOS OBSIDIAN_SUBFOLDER = "" # писать прямо в корень vault ``` После изменения **сохраните файл и перезапустите ComfyUI.** --- ## 🇬🇧 English ### What the node does The **`Save Image + Obsidian Note`** node (category **Obsidian**) does the following for every image: 1. Saves the PNG to ComfyUI's standard `output` folder (normal numbering, with the workflow metadata embedded — just like the built-in `Save Image` node). 2. Copies that PNG into the notes folder (by default `Comfy-Promt` inside your Obsidian vault). 3. Creates a `.md` note next to it **with the same name as the image but without the extension** (e.g. `ComfyUI_00042_.md`). Inside: - the embedded image `![[ComfyUI_00042_.png]]`; - the positive prompt inside a **code block**, so you can copy it in one click. Example note content: ````markdown ![[ComfyUI_00042_.png]] ``` a cinematic portrait of a fox, golden hour, 85mm, highly detailed ``` ```` ### Installation 1. Copy the `comfyui-obsidian-promt` folder into your ComfyUI `custom_nodes` directory. - ComfyUI Desktop / portable: `...\ComfyUI\custom_nodes\` Or clone the repository directly there: ```bash cd /path/to/ComfyUI/custom_nodes git clone http://192.168.1.171:3000/dimon/comfyui-obsidian-promt.git ``` 2. **Configure the save path** (see the section below) — otherwise notes will end up in the wrong folder. 3. **Fully restart ComfyUI.** The node appears in the add-node menu under the **Obsidian** category as **Save Image + Obsidian Note**. No extra dependencies are required: `numpy`, `Pillow` and `folder_paths` already ship with every ComfyUI build. ### How to use Add the **Save Image + Obsidian Note** node at the end of your workflow (instead of or alongside the built-in `Save Image`) and connect `images` to the `VAE Decode` output. The node can obtain the prompt text in two ways, selected with the **`prompt_source`** switch: | Mode | What to connect | Where the text comes from | |------|-----------------|---------------------------| | `string` (default) | the `positive_prompt` input (**STRING**) | the string exactly as you typed it | | `conditioning` | the `positive_conditioning` input (**CONDITIONING**) | the text is traced through the workflow graph back to the `CLIP Text Encode` node and read from its text field | **`string` mode** — connect a string/text node (e.g. `String`/`Text` from comfyui-custom-scripts or KJNodes). Best when the prompt is built dynamically (wildcards / dynamic prompts): tap the string *after* it has been expanded so the final text lands in the note. **`conditioning` mode** — connect the same `CLIP Text Encode` output that feeds your `KSampler`. No separate string node needed. > ⚠️ **Important about `conditioning` mode.** The original text cannot be > recovered from a CONDITIONING tensor (encoding is one-way). Instead the node > walks the workflow graph backwards from the connected input to the > `CLIP Text Encode` node and reads its text field. This is exact for ordinary > static prompts. Intermediate nodes (`Conditioning Combine/Concat`, etc.) are > traversed and their texts are concatenated. If the text is fed into > `CLIP Text Encode` in a non-standard way (some wildcard/BNK nodes), the graph > may only contain a template or nothing — the note will then contain a > `[prompt not found: ...]` marker. Use `string` mode in those cases. The optional `filename_prefix` input (default `ComfyUI`) sets the filename prefix, just like the built-in `Save Image`. ### How to change the save folder Open `__init__.py` and find the **`НАСТРОЙКА ПУТЕЙ / PATH CONFIGURATION`** block near the top. It contains two lines: ```python VAULT_DIR = r"C:\Users\dimir\Documents\ObsidianTask" OBSIDIAN_SUBFOLDER = "Comfy-Promt" ``` - **`VAULT_DIR`** — full path to the Obsidian vault (or any other folder). On Windows use an `r"..."` prefix and backslashes. - **`OBSIDIAN_SUBFOLDER`** — subfolder name inside `VAULT_DIR` where the `.md` notes and `.png` copies go. It is created automatically. Set it to an empty string `""` to write directly into `VAULT_DIR`. Examples: ```python VAULT_DIR = r"D:\MyVault" # different drive VAULT_DIR = r"\\NAS\share\Obsidian" # network share VAULT_DIR = "/home/user/Obsidian" # Linux / macOS OBSIDIAN_SUBFOLDER = "" # write into the vault root ``` After editing, **save the file and restart ComfyUI.** --- ## License MIT