从原始路径加载图片
Load an Image From Any Real Path and Keep the Path — Not Just input/
- image
- mask
- source_image_path
ComfyUI's built-in LoadImage is famously locked to the input/ folder - drop a file anywhere else and it can't see it. KSLoadImageWithPath breaks that restriction: it loads an image from any absolute path on disk (or a path you pick with a system file dialog button) and, crucially, also outputs the resolved absolute path. That path output is the whole reason this node exists in this pack - the downstream save node uses it to know where to put results next to the source file.
What it does
The image_path input takes a filesystem path - png, jpg, jpeg, webp, bmp, tif, tiff - and there's a button that opens your OS's native file picker instead of typing. The loading itself follows ComfyUI's built-in LoadImage behavior closely: EXIF orientation is respected, animated images give you their frames, an alpha channel becomes a mask, and output dtype/device placement match ComfyUI's conventions. So you get standard, predictable behavior - just not restricted to input/.
Three outputs:
image- the RGB tensor.mask- built from the alpha channel; all-black if the file has none.source_image_path- the resolved absolute path. This is the star. Wire it toKSDirectorySaveImages(which creates awhite_backgroundsubfolder next to it) or to the CLI input node (which derives1688_mainoutput paths from it), and your outputs land organized next to your sources automatically.
The file-picker caveat
Browsers can't expose absolute local paths, so the picker runs on the backend via OS-specific dialogs. On Windows it uses Python ctypes to open the native Explorer dialog - no extra install. On Fedora/Linux it shells out to zenity or kdialog, and if neither is installed, the button silently has no way to work:
sudo dnf install -y zenity # or kdialog
That's the single most common "the button does nothing" fix for this pack on Linux. The path text input itself works everywhere - the picker is the only OS-dependent bit.
Installing
With the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/kongshan4219/ComfyUI-Kongshan-Nodes
restart ComfyUI. No models, no keys - but on Linux, install zenity or kdialog for the picker button.
Gotchas
- It validates the path up front.
VALIDATE_INPUTSrejects a path that doesn't resolve to a file, with a clear "Invalid image file: ..." message. Type carefully - a typo fails fast rather than at execution. - It re-loads when the file changes.
IS_CHANGEDis based on a hash of the file, so editing the image on disk and re-queueing actually picks up the new version - unlike nodes that cache by path string forever. - Security note, for real. Being able to load from any absolute path also means this node reads whatever it's told to. That's the feature; just don't pipe untrusted path strings into it (and be aware the pack's CLI executor makes an even bigger trust decision - see
KSAntigravityCLIExecute).
The KB's image-io-metadata essay covers how the standard LoadImage / input/ contract works; this node is the deliberate exception to it, and the path-carrying design is what makes the whole Kongshan "save next to the source" workflow possible. It's the node that makes the pack feel like a real production tool instead of a toy.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image_path | STRING | 输入图片路径。支持 png、jpg、jpeg、webp、bmp、tif、tiff 等 PIL 可读取格式;按钮可打开系统文件选择器。 |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| source_image_path | STRING | — |