ID Photos
Your passport photo, minus the drugstore photo booth
- image
- standard_photo
- hd_photo
- print_photos
ID Photos is the node that turns a single selfie into a regulation-compliant ID photo in one run - background swapped, face cropped to the exact official size, and laid out on a printable sheet. It's the ComfyUI remake of the HivisionIDPhotos pipeline (which the pack's README credits), and for anyone who needs a Chinese-standard ID photo - one-inch 413×295, two-inch 626×413, exam photos, visa photos - it beats the photo booth and beats fiddling with GIMP. Wire one image in, get three outputs out. That's the whole pitch.
What it actually does
Under the hood there are three stages. First, a RetinaFace detector (resnet50) finds and aligns your face, then crops it to the size you picked from the dropdown - which is a list of real Chinese photo standards: 一寸/二寸 (one/two inch), the small and large variants, plus presets for 教师资格证 (teacher certificate), 四六级 (CET exam), 社保卡 (social security card), and US/Japan/Korea visa sizes. Then an RMBG model from the bundled ComfyUI-RMBG code cuts the background out, and drops it on a solid color or leaves it as an alpha layer. Finally it tiles the finished photo onto a print sheet.
The three outputs are the three things you'd otherwise make by hand:
- standard_photo - the exact-size photo, resized to the spec (e.g. 413×295), background applied. This is the file you upload to an application form.
- hd_photo - the same crop at higher resolution, no forced resampling. Handy if you want to print it bigger or touch it up first.
- print_photos - the printable sheet: many copies of the photo tiled onto one canvas, sized by the kb and dpi inputs. For the record, it does the slightly dodgy but very real trick of padding a PNG to hit your target file size in KB - some Chinese systems reject files over a specific byte count, so this is actually the feature.
The inputs that matter
- size - pick your standard. The names are Chinese, but the pixel dimensions are in each label, so you can't really miss.
- bg_color - Alpha leaves a transparent PNG (great for re-grounding later); the named colors include the official greens and blues (pure_blue, cornflower_blue, dark_slate_blue) and neutrals. For a Western passport photo you'll usually want plain white.
- rmbg_model - defaults to RMBG-2.0, which is the right default. BEN2 is the heavier option if hair edges are killing you; the background-removal KB would tell you the frontier has moved, but for clean portrait cutouts any of these is fine.
- face_reduction / face_up_down / angle_offset - fine-tune how much face is in frame and where it sits vertically. Defaults work; nudge
face_up_downif the crop cuts your forehead. - unload_model - true by default, which frees VRAM after the run. Leave it on unless you're chaining many of these.
How to install
Everything lives in one pack, billwuhao/ComfyUI_PortraitTools:
cd ComfyUI/custom_nodes
git clone https://github.com/billwuhao/ComfyUI_PortraitTools.git
cd ComfyUI_PortraitTools
pip install -r requirements.txt # or: ./python_embeded/python.exe -m pip install -r requirements.txt
Dependencies are light - huggingface_hub, opencv-python, PyYAML - since it leans on ComfyUI's bundled torch. The face detector needs detection_Resnet50_Final.pth placed in ComfyUI/models/facedetection/ (download it from the README's link; if you already run ReActor, its model lives in the same folder and is shared). The RMBG model auto-downloads to ComfyUI/models/RMBG/ on first run.
Where people get burned
- "No face detected" or "Multiple faces detected" errors are deliberate. This node refuses to guess - it wants exactly one face, looking reasonably forward. Retry with a cleaner headshot.
- The first run downloads the RMBG weights, so don't panic at a long pause.
- The pack bundles GPL-3.0 RMBG code, which matters if you ever ship a product around this.
- It's a classic detection-crop pipeline, not a generator: feed it a real photo, not a heavily generated face, or the biometric crop gets weird.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| rmbg_model | COMBO | RMBG-2.0 | 4 options: RMBG-2.0, INSPYRENET, BEN, BEN2 |
| unload_model | BOOLEAN | true | — |
| bg_color | COMBO | Alpha | 11 options: Alpha, black, white, gray, green, pure_blue, +5 |
| size | COMBO | 一寸,413,295 | 18 options: 一寸,413,295, 二寸,626,413, 小一寸,378,260, 小二寸,531,413, 大一寸,567,390, 大二寸,626,413, +12 |
| kb | INT | 5005–2000 | — |
| dpi | INT | 30050–1000 | — |
| face_reduction | FLOAT | 1.00–5 | — |
| face_up_down | FLOAT | 0.00-0.5–0.5 | — |
| angle_offset | FLOAT | 1.0-10–10 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| standard_photo | IMAGE | — |
| hd_photo | IMAGE | — |
| print_photos | IMAGE | — |