π Gemini Pro Batch Refine Custom
The Batch Refine twin that lets you set your own aspect
- images
- image_2
- image_3
- image_4
- image_5
- image_6
- image_7
- image_8
- image_9
- image_10
- image_11
- image_12
- refined_images
- summary
- metadata
Gemini Pro Batch Refine Custom is the exact same node as Gemini Pro Batch Refine, with one difference: instead of an aspect_ratio dropdown it hands you custom_width and custom_height inputs. That's the whole story, and it's honestly the better variant for most people, because "let the model decide" is one thing, but sometimes you know your output canvas needs to be, say, 3:2 and you'd rather type it than hunt a preset.
What changed, precisely
Look at the two nodes side by side and the only real difference is in the required inputs. The standard node has the aspect_ratio preset list; this one strips that dropdown and drops two INT inputs - custom_width and custom_height, both defaulting to 1024 - right after image_size. Everything else is inherited: the same images list input, the same system_prompt with its {image_1} through {image_12} placeholders, the same image_2 β¦ image_12 reference-shot inputs, seed, temperature, additional_prompt, project_name, and stop_on_error. Outputs are identical too: refined_images (a list), summary, metadata.
One wrinkle worth knowing before you assume your exact width is what comes out: Gemini's API only accepts a fixed enum of aspect strings. The node takes your width and height, works out the ratio, and snaps it to the closest supported preset - 1:1, 4:3, 16:9, and so on. It prints which preset it snapped to in the console, so a custom_width of 900 with custom_height of 1200 becomes a 3:4 request. The image_size tier (1K/2K/4K) still sets the resolution independent of that ratio. Don't treat the numbers as a strict canvas; treat them as "aim the aspect at this."
When to reach for it
If your workflow already has a resolution node computing an aspect from arbitrary inputs - a product-image layout, a specific print ratio, a downstream compositor that expects a particular frame - the Custom variant lets you wire that math straight in instead of converting it to a preset label by hand. If you never think about aspect, the standard node's custom option does the same "keep the base image's framing" thing with less input. Pick Custom when you want explicit control, standard when you want fewer knobs.
Everything else from the base node applies unchanged, including the things that cost you money. It's an API node: it needs a GOOGLE_API_KEY (via the pack's .env, an environment variable, or the input field), it calls Nano Banana Pro per iteration, and a batch of N images is N paid generations with your reference shots riding along. The default prompt is the garment identity-lock refinement contract, so if that's not your use case, replace it.
Install and gotchas
Same pack, same install: ComfyUI Manager (search "ComfyUI_Gemini"), or git clone https://github.com/aarnoatchi/ComfyUI_Gemini into custom_nodes and pip install -r requirements.txt. The pack depends on google-genai (never google-generativeai) plus python-dotenv and scipy. Watch the model list - the *-image-preview names get retired by Google, so if a model stops responding, switch to the GA name like gemini-3-pro-image. And keep stop_on_error off unless you want the whole batch to die on the first bad call - the placeholder-insertion behavior is what keeps your refined list index-aligned with alphas_list downstream.
Inputs (22)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | Per-iteration {image_1} base. Wire from Mask Crop.images_list (native-size list) or any IMAGE/IMAGE-batch source. Each entry is refined separately against the same reference shots. | |
| model | COMBO | gemini-3-pro-image | 4 options: gemini-3-pro-image-preview, gemini-3-pro-image, gemini-3.1-flash-image-preview, gemini-3.1-flash-image |
| system_prompt | STRING | Refine the details in a cropped garment image using close-up reference shots, while keeping the entire image absolutely identical to the input. INPUTS {image_1}: The cropped area of the garment image that needs refinement β this is the base image. The output must match this exactly in every way except the specific details being corrected {image_2}, {image_3}, {image_4}, {image_5}: Detail reference shots β the MASTER REFERENCE for the correct logos, labels, hardware, stitching, trims, text, or any other detail that needs to be refined TASK Reproduce {image_1} pixel-perfectly, with one change only: replace any incorrect, blurry, hallucinated, or imprecise detail with the accurate version sourced from the reference shots. OUTPUT RULES Identity Lock β CRITICAL: - The output must be the exact same image as {image_1} β same crop, same framing, same angle, same perspective, same lighting, same background, same fabric texture, same folds, same wrinkles, same shadows - Do NOT reframe, zoom, rotate, rescale, or recompose the image in any way - Do NOT change the image format from flat lay to 3D, from 3D to flat lay, or into any other presentation style - Do NOT add volume, remove volume, alter the garment shape, or change any structural element - Do NOT alter lighting, color temperature, grain, sharpness, or depth of field - The only permitted change is the correction of specific detail content β everything else is frozen Detail Refinement from the reference shots β CRITICAL: - Study each detail reference at the highest possible fidelity before generating - Every character, stroke, color, spacing, proportion, and finish in the reference must be reproduced in the refined output - Logos: exact shape, color, typography, and layout β no simplification, no approximation, no invention - Text: every letter must match the reference exactly β correct font weight, kerning, capitalization, and color - Labels and tags: exact label design, stitching style, and placement as shown in the reference - Hardware: exact shape, finish, and material appearance - Stitching and trims: exact stitch density, color, and construction - Treat each reference image as a forensic document β copy it, do not interpret it Integration β CRITICAL: - The refined detail must sit naturally within the existing image β matching the perspective, scale, lighting, and surface texture of the surrounding area in {image_1} - The boundary between the refined area and the surrounding image must be seamless β no visible edge, no color shift, no sharpness difference, no halo - The corrected detail must look as if it was always correct in {image_1} β not patched, not composited, not replaced NEGATIVE RULES - Do NOT change the image style, format, or presentation in any way - Do NOT convert flat lay to 3D or 3D to flat lay - Do NOT alter garment shape, volume, or structure - Do NOT change lighting, shadows, grain, or color temperature - Do NOT reframe, crop differently, zoom in or out, or rotate - Do NOT invent details not present in the reference shots - Do NOT alter any area of the image outside the detail being corrected - Do NOT smooth, sharpen, or retouch the image beyond what is necessary for the detail correction PRIORITY ORDER 1. Output is identical to {image_1} in every way β same crop, same style, same lighting, same structure 2. Correct detail content reproduced with forensic accuracy from the reference shots 3. Seamless integration β corrected detail matches surrounding perspective, scale, and lighting 4. Zero visible boundary between corrected area and rest of image 5. No changes outside the specific detail being corrected OUTPUT One image identical to {image_1} in every way β same crop, same framing, same style, same lighting β with only the incorrect detail replaced by the accurate version sourced from the reference shots, integrated seamlessly so the correction is invisible and the result reads as the original image always being correct. The logic is simple: {image_1} is the contract for everything β format, style, lighting, structure. The reference shots are the contract for detail content only. Nothing else changes. | Prompt used for every iteration. {image_1} is the per-iteration base; {image_2}..{image_12} reference the optional reference inputs. |
| image_size | COMBO | 2K | 3 options: 1K, 2K, 4K |
| custom_width | INT | 102464β4096 | Defines the output aspect ratio together with custom_height. Gemini snaps to the closest supported preset (1:1, 4:3, 16:9, β¦); image_size still picks 1K/2K/4K for the resolution tier. |
| custom_height | INT | 102464β4096 | See custom_width. |
| seed | INT | 00β2147483647 | 0 = random per iteration. Non-zero seeds yield seed+i for the i-th item, so the same seed gives reproducible refinements across the whole batch. |
| temperature | FLOAT | 1.000β1 | β |
| image_2opt | IMAGE | β | |
| image_3opt | IMAGE | β | |
| image_4opt | IMAGE | β | |
| image_5opt | IMAGE | β | |
| image_6opt | IMAGE | β | |
| image_7opt | IMAGE | β | |
| image_8opt | IMAGE | β | |
| image_9opt | IMAGE | β | |
| image_10opt | IMAGE | β | |
| image_11opt | IMAGE | β | |
| image_12opt | IMAGE | β | |
| additional_promptopt | STRING | β | |
| project_nameopt | STRING | β | |
| stop_on_erroropt | BOOLEAN | false | If True, abort the batch on the first failed iteration. If False (default), insert a (1,1,1,3) placeholder and continue, preserving index alignment with downstream alphas_list. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| refined_images | IMAGE | β |
| summary | STRING | β |
| metadata | DICT | β |