아웃페인트: 원하는 비율로 확장 - Nano Banana Pro
이미지를 업로드하고, 원하는 종횡비와 새 캔버스에서 이미지의 위치(%)를 입력하세요. Nano Banana Pro를 사용해 새 비율에 맞게 이미지를 아웃페인트합니다.
정보
이 ComfyUI 워크플로는 원본을 자르거나 왜곡하지 않고 단일 이미지를 원하는 비율로 아웃페인팅합니다. LoadImage로 이미지를 불러온 뒤, 커스텀 Image Extender 노드(b26cc822-68bf-4fd0-b66f-bb3f99cd1443)가 선택한 비율에 맞춰 새 캔버스를 만들고, 사용자 지정 위치(퍼센트)로 원본을 고정합니다. 새로 추가된 캔버스 영역만 생성되며 원본 픽셀은 그대로 유지됩니다. 내부적으로 Image Extender는 Nano Banana Pro 모델을 사용한 디퓨전 과정을 래핑해, 소스와 자연스럽게 블렌딩되는 주변 콘텐츠를 합성합니다.
보조 노드로 과정이 명확하고 반복 가능해집니다. GetImageSize가 소스 크기를 읽고, ImageResizeKJv2는 입력 또는 출력 스케일을 선택적으로 조정해 디테일을 더 깔끔하게 만들 수 있습니다. PreviewImage/ImageCompare로 이전/이후 결과를 평가합니다. 가이드된 생성을 원하면 GeminiImage2Node가 이미지 기반 프롬프트를 제공해 Image Extender로 전달할 수 있습니다. 만족하면 SaveImage로 최종 아웃페인팅 결과를 저장합니다. 정밀한 배치 제어, 비율 타깃팅, 아웃페인팅에 적합한 모델 조합으로, 핵심 콘텐츠를 잃지 않고 소셜/웹/인쇄 형식에 맞게 이미지를 재활용하기에 실용적입니다.
제공할 항목
- 워크플로 읽는 중
ComfyUI에서 실행됩니다. 이 워크플로는 이 페이지에서 실행할 수 없습니다. 모든 항목이 로드된 Comfy Cloud에서 열거나, 자체 ComfyUI에서 사용하려면 다운로드하세요.
Cloud에서 사용해 보기워크플로 내부
노드 그래프의 읽기 전용 미리보기입니다. 노드를 편집하려면 Comfy Cloud에서 열거나 다운로드하세요.
Loading the graph
Open full-size workflow preview- 작성자
- Rob
사용자 지정 노드 필요
- 워크플로 읽는 중
코드에서 이 워크플로 사용하기
가능한 경우 워크플로 그래프와 입력을 기반으로 생성되며, 그렇지 않은 경우 저장된 예시가 표시됩니다. 비용이 발생할 수 있으므로 코드를 실행하기 전에 자격 증명과 엔드포인트를 검토하세요.
What you need
- Runs on
- Comfy Cloud
- 키
- COMFY_API_KEY
- 내 파일
- 코드가 해당 URL에서 업로드
유료 Cloud 요금제와 크레딧이 필요합니다.
# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"130": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"226": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"224:249",
0
]
},
"_meta": {
"title": "Preview Image"
}
},
"262": {
"class_type": "ImageCompare",
"inputs": {
"compare_view": None,
"image_a": [
"263",
0
],
"image_b": [
"264",
0
]
},
"_meta": {
"title": "Compare Images"
}
},
"263": {
"class_type": "GeminiImage2Node",
"inputs": {
"aspect_ratio": "auto",
"images": [
"224:249",
0
],
"model": "gemini-3-pro-image-preview",
"prompt": "Outpaint/fill the green pixels. Retain composition of the visible images pixels. Analyze the original image content to understand what the outpainted region should be. \nDO NOT MODIFY the original images pixels. It must remain exactly as is. ONLY ALTER THE GREEN PIXELS.\nThe green outpainted pixels must seamlessly blend into the scene. DO NOT COPY/PASTE existing pixels into the target outpainted area.",
"resolution": "4K",
"response_modalities": "IMAGE+TEXT",
"seed": 0,
"system_prompt": "You are an expert image-generation engine. You must ALWAYS produce an image.\nInterpret all user input—regardless of format, intent, or abstraction—as literal visual directives for image composition.\nIf a prompt is conversational or lacks specific visual details, you must creatively invent a concrete visual scenario that depicts the concept.\nPrioritize generating the visual representation above any text, formatting, or conversational requests."
},
"_meta": {
"title": "Nano Banana Pro (Google Gemini Image)"
}
},
"264": {
"class_type": "ImageResizeKJv2",
"inputs": {
"crop_position": "center",
"device": "cpu",
"divisible_by": 2,
"height": [
"265",
1
],
"image": [
"224:249",
0
],
"keep_proportion": "stretch",
"pad_color": "0, 0, 0",
"upscale_method": "lanczos",
"width": [
"265",
0
]
},
"_meta": {
"title": "Resize Image v2"
}
},
"265": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"263",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"266": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-outpainted",
"images": [
"263",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"224:191": {
"class_type": "FluxResolutionNode",
"inputs": {
"aspect_ratio": "32:9 (Extreme Ultrawide)",
"custom_aspect_ratio": "1:1",
"custom_ratio": False,
"divisible_by": "8",
"megapixel": "2.1"
},
"_meta": {
"title": "Flux Resolution Calc"
}
},
"224:240": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 50
},
"_meta": {
"title": "top_or_left_outpaint_pct"
}
},
"224:241": {
"class_type": "ImageResize+",
"inputs": {
"condition": "always",
"height": [
"224:191",
1
],
"image": [
"130",
0
],
"interpolation": "lanczos",
"method": "keep proportion",
"multiple_of": 0,
"width": [
"224:191",
0
]
},
"_meta": {
"title": "🔧 Image Resize"
}
},
"224:242": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "floor((a - b) * (c / 100))",
"values.a": [
"224:191",
0
],
"values.b": [
"224:241",
1
],
"values.c": [
"224:240",
0
]
},
"_meta": {
"title": "pad_left"
}
},
"224:243": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "(a - b) - floor((a - b) * (c / 100))",
"values.a": [
"224:191",
0
],
"values.b": [
"224:241",
1
],
"values.c": [
"224:240",
0
]
},
"_meta": {
"title": "pad_right"
}
},
"224:244": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "floor((a - b) * (c / 100))",
"values.a": [
"224:191",
1
],
"values.b": [
"224:241",
2
],
"values.c": [
"224:240",
0
]
},
"_meta": {
"title": "pad_top"
}
},
"224:245": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "(a - b) - floor((a - b) * (c / 100))",
"values.a": [
"224:191",
1
],
"values.b": [
"224:241",
2
],
"values.c": [
"224:240",
0
]
},
"_meta": {
"title": "pad_bottom"
}
},
"224:246": {
"class_type": "ImagePadForOutpaint",
"inputs": {
"bottom": [
"224:245",
1
],
"feathering": 0,
"image": [
"224:241",
0
],
"left": [
"224:242",
1
],
"right": [
"224:243",
1
],
"top": [
"224:244",
1
]
},
"_meta": {
"title": "Pad Image for Outpainting"
}
},
"224:247": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"224:246",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"224:248": {
"class_type": "EmptyImage",
"inputs": {
"batch_size": 1,
"color": 65280,
"height": [
"224:247",
1
],
"width": [
"224:247",
0
]
},
"_meta": {
"title": "Empty Image"
}
},
"224:249": {
"class_type": "ImageCompositeMasked",
"inputs": {
"destination": [
"224:246",
0
],
"mask": [
"224:246",
1
],
"resize_source": False,
"source": [
"224:248",
0
],
"x": 0,
"y": 0
},
"_meta": {
"title": "Image Composite Masked"
}
}
})
# Replace each example.com URL with a public URL of your file.
workflow.set_input("130", "image", client.assets.from_url("https://example.com/replace-with-a-url/image"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)질문과 답변
Image Extender는 목표 비율에 맞는 새 캔버스를 만든 다음, 지정한 X/Y 퍼센트 위치에 원본 이미지를 배치합니다. 퍼센트는 캔버스에 매핑됩니다: 0%는 좌/상, 50%는 중앙, 100%는 우/하입니다. 비어 있는 영역은 Nano Banana Pro가 채우고, 원본 픽셀은 보존됩니다.
아니오. 워크플로는 생성된 콘텐츠 위에 원본을 변경 없이 합성합니다. 새로 추가된 캔버스 영역만 합성되며, 소스 픽셀은 로딩된 그대로 유지됩니다.
필수는 아닙니다. Nano Banana Pro는 소스 이미지에서 컨텍스트를 추론할 수 있지만, 짧은 프롬프트가 스타일 일관성에 도움이 되는 경우가 많습니다(예: "soft natural light, cohesive background"). Image Extender에 프롬프트를 직접 입력(가능한 경우)하거나 GeminiImage2Node로 이미지에서 자동 제안 프롬프트를 만들 수 있습니다.
첫 패스에서는 확장 폭을 과도하게 늘리지 말고, 출력 크기가 8의 배수가 되도록 합니다. Image Extender에 steps 또는 denoise 같은 설정이 있다면 약간 올린 뒤 다시 실행해 보세요. 피사체 위치(퍼센트)를 옮겨 아웃페인팅 방향에 더 많은 공간을 주는 것도 도움이 됩니다. VRAM이 부족하면 ImageResizeKJv2로 다운스케일해 아웃페인팅한 뒤, 나중에 업스케일링하세요.