画像のリサイズとクロップ
画像のサイズを大きくしたり正方形にクロップ(切り抜き)したり…という単純なタスクですが、画像生成においてはとても重要な作業です。
- モデルの適正解像度: モデルには「最も性能を発揮できる解像度」があります。
- VRAMの節約: うっかり4Kの画像を読み込んで処理すると、一瞬で「Out of memory」になります。
- 素材の統一: 画像合成などで、複数の素材サイズを揃える必要があります。
出番の多い作業なので、それぞれのノードの違いをしっかり理解しましょう。
画像情報の取得
Get Image Size ノード
画像の幅(width)と高さ(height)、バッチサイズ(枚数)を数値として出力します。

{
"id": "c4311028-f464-4d21-a079-ea6457b21328",
"revision": 0,
"last_node_id": 13,
"last_link_id": 15,
"nodes": [
{
"id": 2,
"type": "LoadImage",
"pos": [
1429.7952880859375,
120.70687473761723
],
"size": [
276.28009033203125,
393.20001220703125
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
9
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadImage",
"cnr_id": "comfy-core",
"ver": "0.3.36"
},
"widgets_values": [
"example.png",
"image"
]
},
{
"id": 13,
"type": "PreviewAny",
"pos": [
2037.9461794184988,
353.61446301710606
],
"size": [
210,
166
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "source",
"type": "*",
"link": 15
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewAny"
},
"widgets_values": [
null,
null,
null
]
},
{
"id": 12,
"type": "PreviewAny",
"pos": [
2037.946179418499,
120.70687473761723
],
"size": [
210,
166
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "source",
"type": "*",
"link": 14
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewAny"
},
"widgets_values": [
null,
null,
false
]
},
{
"id": 10,
"type": "GetImageSize",
"pos": [
1767.0107789182339,
120.70687473761723
],
"size": [
210,
136
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 9
}
],
"outputs": [
{
"name": "width",
"type": "INT",
"links": [
14
]
},
{
"name": "height",
"type": "INT",
"links": [
15
]
},
{
"name": "batch_size",
"type": "INT",
"links": null
}
],
"properties": {
"Node name for S&R": "GetImageSize",
"cnr_id": "comfy-core",
"ver": "0.3.39"
},
"widgets_values": [
"width: 768, height: 768\n batch size: 1"
],
"color": "#232",
"bgcolor": "#353"
}
],
"links": [
[
9,
2,
0,
10,
0,
"IMAGE"
],
[
14,
10,
0,
12,
0,
"INT"
],
[
15,
10,
1,
13,
0,
"INT"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 1.1,
"offset": [
-929.1612871706993,
295.0754618992246
]
},
"frontendVersion": "1.38.4",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
リサイズ
Resize Image/Mask ノード
いくつものリサイズ方法を切り替えて使えるノードです。
基本的には、これ一つで必要な処理をだいたい網羅できます。(ちなみにマスクもリサイズできます)
{
"id": "0836caf4-d27b-44b2-8cab-34ce133141f9",
"revision": 0,
"last_node_id": 3,
"last_link_id": 2,
"nodes": [
{
"id": 2,
"type": "LoadImage",
"pos": [
510.0624955533383,
195.92614382699202
],
"size": [
355.63636363636374,
326
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
1
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"Image_fx.jpg",
"image"
]
},
{
"id": 3,
"type": "PreviewImage",
"pos": [
1214.9702576907946,
195.92614382699202
],
"size": [
616.7768595041321,
392.198347107438
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 2
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 1,
"type": "ResizeImageMaskNode",
"pos": [
908.3345584402483,
195.92614382699202
],
"size": [
264,
106
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "input",
"type": "IMAGE,MASK",
"link": 1
}
],
"outputs": [
{
"name": "resized",
"type": "IMAGE",
"links": [
2
]
}
],
"properties": {
"Node name for S&R": "ResizeImageMaskNode"
},
"widgets_values": [
"scale by multiplier",
1.5,
"nearest-exact"
],
"color": "#232",
"bgcolor": "#353"
}
],
"links": [
[
1,
2,
0,
1,
0,
"IMAGE"
],
[
2,
1,
0,
3,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 1,
"offset": [
-121.54552426367871,
302.38818173595405
]
},
"frontendVersion": "1.38.4",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
scale by multiplier
縦横を「倍率」で拡大・縮小します。
たとえば 0.5 なら縦横が半分、2.0 なら縦横が2倍です。
{
"id": "0836caf4-d27b-44b2-8cab-34ce133141f9",
"revision": 0,
"last_node_id": 5,
"last_link_id": 4,
"nodes": [
{
"id": 2,
"type": "LoadImage",
"pos": [
510.0624955533383,
195.92614382699202
],
"size": [
355.63636363636374,
326
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
1,
4
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"Image_fx.jpg",
"image"
]
},
{
"id": 1,
"type": "ResizeImageMaskNode",
"pos": [
908.3345584402483,
195.92614382699202
],
"size": [
264,
154
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "input",
"type": "IMAGE,MASK",
"link": 1
}
],
"outputs": [
{
"name": "resized",
"type": "IMAGE",
"links": [
2
]
}
],
"properties": {
"Node name for S&R": "ResizeImageMaskNode"
},
"widgets_values": [
"scale dimensions",
768,
1024,
"disabled",
"nearest-exact"
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 3,
"type": "PreviewImage",
"pos": [
1214.9702576907946,
195.92614382699202
],
"size": [
332.9768595041321,
398.798347107438
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 2
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 4,
"type": "PreviewImage",
"pos": [
1214.9702576907946,
645.9338317877124
],
"size": [
332.9768595041321,
413.0983471074381
],
"flags": {},
"order": 4,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 3
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 5,
"type": "ResizeImageMaskNode",
"pos": [
912.6802425206289,
645.9338317877124
],
"size": [
264,
154
],
"flags": {
"collapsed": false
},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "input",
"type": "IMAGE,MASK",
"link": 4
}
],
"outputs": [
{
"name": "resized",
"type": "IMAGE",
"links": [
3
]
}
],
"properties": {
"Node name for S&R": "ResizeImageMaskNode"
},
"widgets_values": [
"scale dimensions",
767,
1024,
"center",
"nearest-exact"
],
"color": "#323",
"bgcolor": "#535"
}
],
"links": [
[
1,
2,
0,
1,
0,
"IMAGE"
],
[
2,
1,
0,
3,
0,
"IMAGE"
],
[
3,
5,
0,
4,
0,
"IMAGE"
],
[
4,
2,
0,
5,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.8264462809917354,
"offset": [
113.64883367771927,
235.47609515443676
]
},
"frontendVersion": "1.38.4",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
scale dimensions
指定した幅・高さの解像度に強制的に変更します。
cropdisabled: アスペクト比が違う場合は歪みます。center: 中心を維持してはみ出た部分をクロップ(切り捨て)します。
{
"id": "0836caf4-d27b-44b2-8cab-34ce133141f9",
"revision": 0,
"last_node_id": 3,
"last_link_id": 2,
"nodes": [
{
"id": 2,
"type": "LoadImage",
"pos": [
510.0624955533383,
195.92614382699202
],
"size": [
355.63636363636374,
326
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
1
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"Image_fx.jpg",
"image"
]
},
{
"id": 1,
"type": "ResizeImageMaskNode",
"pos": [
908.3345584402483,
195.92614382699202
],
"size": [
264,
106
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "input",
"type": "IMAGE,MASK",
"link": 1
}
],
"outputs": [
{
"name": "resized",
"type": "IMAGE",
"links": [
2
]
}
],
"properties": {
"Node name for S&R": "ResizeImageMaskNode"
},
"widgets_values": [
"scale longer dimension",
1024,
"nearest-exact"
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 3,
"type": "PreviewImage",
"pos": [
1214.9702576907946,
195.92614382699202
],
"size": [
500.63636363636374,
324
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 2
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
}
],
"links": [
[
1,
2,
0,
1,
0,
"IMAGE"
],
[
2,
1,
0,
3,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 1,
"offset": [
-89.54552426367871,
278.38818173595405
]
},
"frontendVersion": "1.38.4",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
scale longer/shorter dimension
長辺(longer)または短辺(shorter)だけを指定し、アスペクト比を保ったままリサイズします。
{
"id": "0836caf4-d27b-44b2-8cab-34ce133141f9",
"revision": 0,
"last_node_id": 3,
"last_link_id": 2,
"nodes": [
{
"id": 3,
"type": "PreviewImage",
"pos": [
1214.9702576907946,
195.92614382699202
],
"size": [
500.63636363636374,
324
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 2
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 2,
"type": "LoadImage",
"pos": [
510.0624955533383,
195.92614382699202
],
"size": [
355.63636363636374,
326
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
1
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"Image_fx.jpg",
"image"
]
},
{
"id": 1,
"type": "ResizeImageMaskNode",
"pos": [
908.3345584402483,
195.92614382699202
],
"size": [
264,
106
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "input",
"type": "IMAGE,MASK",
"link": 1
}
],
"outputs": [
{
"name": "resized",
"type": "IMAGE",
"links": [
2
]
}
],
"properties": {
"Node name for S&R": "ResizeImageMaskNode"
},
"widgets_values": [
"scale width",
1024,
"nearest-exact"
],
"color": "#232",
"bgcolor": "#353"
}
],
"links": [
[
1,
2,
0,
1,
0,
"IMAGE"
],
[
2,
1,
0,
3,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 1,
"offset": [
-89.54552426367871,
278.38818173595405
]
},
"frontendVersion": "1.38.4",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
scale width/height
幅または高さのどちらか一方だけを指定し、アスペクト比を保ったままリサイズします。
{
"id": "0836caf4-d27b-44b2-8cab-34ce133141f9",
"revision": 0,
"last_node_id": 3,
"last_link_id": 2,
"nodes": [
{
"id": 3,
"type": "PreviewImage",
"pos": [
1214.9702576907946,
195.92614382699202
],
"size": [
500.63636363636374,
324
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 2
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 2,
"type": "LoadImage",
"pos": [
510.0624955533383,
195.92614382699202
],
"size": [
355.63636363636374,
326
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
1
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"Image_fx.jpg",
"image"
]
},
{
"id": 1,
"type": "ResizeImageMaskNode",
"pos": [
908.3345584402483,
195.92614382699202
],
"size": [
264,
106
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "input",
"type": "IMAGE,MASK",
"link": 1
}
],
"outputs": [
{
"name": "resized",
"type": "IMAGE",
"links": [
2
]
}
],
"properties": {
"Node name for S&R": "ResizeImageMaskNode"
},
"widgets_values": [
"scale total pixels",
1,
"nearest-exact"
],
"color": "#232",
"bgcolor": "#353"
}
],
"links": [
[
1,
2,
0,
1,
0,
"IMAGE"
],
[
2,
1,
0,
3,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 1,
"offset": [
-89.54552426367871,
278.38818173595405
]
},
"frontendVersion": "1.38.4",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
scale total pixels
指定した 総ピクセル数(画素数) になるように、アスペクト比を保ったままリサイズします。
1024 * 1024 = 1.00MPとして計算されます。
| 目標サイズ | 総ピクセル数 | 設定値 |
|---|---|---|
| 512 × 512 | 262,144 | 0.25 |
| 768 × 768 | 589,824 | 0.56 |
| 1024 × 1024 | 1,048,576 | 1.00 |
| 1536 × 1536 | 2,359,296 | 2.25 |
{
"id": "0836caf4-d27b-44b2-8cab-34ce133141f9",
"revision": 0,
"last_node_id": 6,
"last_link_id": 6,
"nodes": [
{
"id": 1,
"type": "ResizeImageMaskNode",
"pos": [
893.7663906331555,
88.11514382699193
],
"size": [
264,
126
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "input",
"type": "IMAGE,MASK",
"link": 1
},
{
"label": "match",
"name": "resize_type.match",
"type": "IMAGE,MASK",
"link": 3
}
],
"outputs": [
{
"name": "resized",
"type": "IMAGE",
"links": [
2
]
}
],
"properties": {
"Node name for S&R": "ResizeImageMaskNode"
},
"widgets_values": [
"match size",
"disabled",
"nearest-exact"
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 4,
"type": "LoadImage",
"pos": [
546.2634955533385,
563.3387801906282
],
"size": [
280.83636363636367,
463.5
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
3,
6
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"ComfyUI_03750_.png",
"image"
]
},
{
"id": 3,
"type": "PreviewImage",
"pos": [
1224.432922076609,
88.11514382699193
],
"size": [
306.3103636363637,
401.19800000000004
],
"flags": {},
"order": 4,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 2
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 5,
"type": "PreviewImage",
"pos": [
1224.4329220766087,
563.3387801906282
],
"size": [
306.3103636363637,
401.19800000000004
],
"flags": {},
"order": 5,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 4
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 2,
"type": "LoadImage",
"pos": [
471.4634955533385,
88.11514382699193
],
"size": [
355.63636363636374,
326
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
1,
5
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"Image_fx.jpg",
"image"
]
},
{
"id": 6,
"type": "ResizeImageMaskNode",
"pos": [
893.7663906331554,
563.3387801906282
],
"size": [
264,
126
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "input",
"type": "IMAGE,MASK",
"link": 5
},
{
"label": "match",
"name": "resize_type.match",
"type": "IMAGE,MASK",
"link": 6
}
],
"outputs": [
{
"name": "resized",
"type": "IMAGE",
"links": [
4
]
}
],
"properties": {
"Node name for S&R": "ResizeImageMaskNode"
},
"widgets_values": [
"match size",
"center",
"nearest-exact"
],
"color": "#323",
"bgcolor": "#535"
}
],
"links": [
[
1,
2,
0,
1,
0,
"IMAGE"
],
[
2,
1,
0,
3,
0,
"IMAGE"
],
[
3,
4,
0,
1,
1,
"IMAGE"
],
[
4,
6,
0,
5,
0,
"IMAGE"
],
[
5,
2,
0,
6,
0,
"IMAGE"
],
[
6,
4,
0,
6,
1,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.7513148009015777,
"offset": [
169.77265899211667,
324.0208561730081
]
},
"frontendVersion": "1.38.4",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
match size
参照画像と同じサイズになるようにリサイズします。
以前は参照画像のサイズを取得して、それを別ノードへ渡す必要がありましたが、これで一つにまとまります。
match: 基準にしたい画像を接続cropdisabled: アスペクト比が違う場合は歪みます。center: 中心を維持してはみ出た部分をクロップ(切り捨て)します。
{
"id": "0836caf4-d27b-44b2-8cab-34ce133141f9",
"revision": 0,
"last_node_id": 3,
"last_link_id": 2,
"nodes": [
{
"id": 3,
"type": "PreviewImage",
"pos": [
1214.9702576907946,
195.92614382699202
],
"size": [
500.63636363636374,
324
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 2
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 2,
"type": "LoadImage",
"pos": [
510.0624955533383,
195.92614382699202
],
"size": [
355.63636363636374,
326
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
1
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"Image_fx.jpg",
"image"
]
},
{
"id": 1,
"type": "ResizeImageMaskNode",
"pos": [
908.3345584402483,
195.92614382699202
],
"size": [
264,
106
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "input",
"type": "IMAGE,MASK",
"link": 1
}
],
"outputs": [
{
"name": "resized",
"type": "IMAGE",
"links": [
2
]
}
],
"properties": {
"Node name for S&R": "ResizeImageMaskNode"
},
"widgets_values": [
"scale to multiple",
32,
"nearest-exact"
],
"color": "#232",
"bgcolor": "#353"
}
],
"links": [
[
1,
2,
0,
1,
0,
"IMAGE"
],
[
2,
1,
0,
3,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.9090909090909091,
"offset": [
-30.34552426367867,
419.4881817359541
]
},
"frontendVersion": "1.38.4",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
scale to multiple
縦横を N の倍数 になるようにリサイズします。
詳しくは 8の倍数の解像度しか生成できないのはなぜ? で解説しますが、拡散モデルは VAEの都合で、特定の倍数になっていない解像度をそのまま扱えません。
基本的にはどこかのノードで自動調整されることも多いのですが、指定解像度でないとエラーが出るケースや、入力と出力でピクセルを「完全一致」させたいケースで使うことがあります。
ImageScaleToMaxDimension ノード
画像の長辺が設定したサイズになるように、アスペクト比を保ったままリサイズします。
(例:縦長の画像でも横長の画像でも、長い方が1024pxになるようにする)

{
"id": "5afabc21-bbd6-4ea3-bd3a-ce4c1dedc9c8",
"revision": 0,
"last_node_id": 60,
"last_link_id": 88,
"nodes": [
{
"id": 53,
"type": "LoadImage",
"pos": [
141,
157
],
"size": [
318.50177001953125,
400.92742919921875
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"slot_index": 0,
"links": [
87
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.59",
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"example.png",
"image"
]
},
{
"id": 54,
"type": "PreviewImage",
"pos": [
822,
157
],
"size": [
567.1885375976562,
593.7391967773438
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 88
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.59",
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 60,
"type": "ImageScaleToMaxDimension",
"pos": [
529,
157
],
"size": [
221.20272827148438,
82
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 87
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
88
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.59",
"Node name for S&R": "ImageScaleToMaxDimension"
},
"widgets_values": [
"area",
1024
],
"color": "#232",
"bgcolor": "#353"
}
],
"links": [
[
87,
53,
0,
60,
0,
"IMAGE"
],
[
88,
60,
0,
54,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 1.3310000000000004,
"offset": [
-41,
-57
]
},
"frontendVersion": "1.28.0",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
パディング
パディングとは、画像の周囲に余白(黒帯など)を追加して、サイズを調整する処理のことです。
ノードによっては、この余白部分をマスクとして出力できるため、Outpaintingを行う際の下準備として使われます。
ResizeAndPadImage ノード
指定した解像度に合わせてリサイズし、足りない部分をパディングで埋めます。

{
"id": "3c344b31-2cca-43a0-acc2-33295e766391",
"revision": 0,
"last_node_id": 16,
"last_link_id": 15,
"nodes": [
{
"id": 3,
"type": "PreviewImage",
"pos": [
2443.600341796875,
382.6131591796875
],
"size": [
474.1802079876393,
354.5867351287129
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 15
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.44",
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 1,
"type": "LoadImage",
"pos": [
1804.466796875,
382.6131591796875
],
"size": [
269.2518615722656,
346.83184814453125
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
14
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.44",
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"example.png",
"image"
]
},
{
"id": 16,
"type": "ResizeAndPadImage",
"pos": [
2123.6595001220703,
382.6131591796875
],
"size": [
270,
130
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 14
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
15
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.71",
"Node name for S&R": "ResizeAndPadImage"
},
"widgets_values": [
768,
512,
"white",
"area"
],
"color": "#232",
"bgcolor": "#353"
}
],
"links": [
[
14,
1,
0,
16,
0,
"IMAGE"
],
[
15,
16,
0,
3,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.8390545288824027,
"offset": [
-1704.466796875,
-282.6131591796875
]
},
"frontendVersion": "1.30.6",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
このノードはパディング部分をマスクとして出力できないため、ほとんど使う場面はありません。
Pad Image for Outpainting ノード
画像の上下左右に、指定したピクセル数だけ余白を追加します。

{
"id": "3c344b31-2cca-43a0-acc2-33295e766391",
"revision": 0,
"last_node_id": 15,
"last_link_id": 13,
"nodes": [
{
"id": 1,
"type": "LoadImage",
"pos": [
1804.466796875,
382.6131591796875
],
"size": [
269.2518615722656,
346.83184814453125
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
5
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.44",
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"example.png",
"image"
]
},
{
"id": 3,
"type": "PreviewImage",
"pos": [
2443.600341796875,
382.6131591796875
],
"size": [
474.1802079876393,
354.5867351287129
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 11
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.44",
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 11,
"type": "ImagePadForOutpaint",
"pos": [
2123.6595001220703,
382.6131591796875
],
"size": [
270,
174
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 5
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
11
]
},
{
"name": "MASK",
"type": "MASK",
"links": [
13
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.71",
"Node name for S&R": "ImagePadForOutpaint"
},
"widgets_values": [
200,
0,
200,
0,
100
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 15,
"type": "MaskPreview",
"pos": [
2443.3892916386476,
798.584304191316
],
"size": [
473.1249524060131,
350.69641361331855
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "mask",
"type": "MASK",
"link": 13
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.71",
"Node name for S&R": "MaskPreview"
},
"widgets_values": []
}
],
"links": [
[
5,
1,
0,
11,
0,
"IMAGE"
],
[
11,
11,
0,
3,
0,
"IMAGE"
],
[
13,
11,
1,
15,
0,
"MASK"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.6934334949441344,
"offset": [
-1704.466796875,
-282.6131591796875
]
},
"frontendVersion": "1.30.6",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
余白部分がマスクとして出力されます。
- feathering: 余白と画像の境界をぼかします。マスクにしか影響しません。
クロップその他の編集操作
ImageCrop ノード
x, y座標と幅・高さを指定して、画像の一部分を矩形で切り抜きます。

{
"last_node_id": 58,
"last_link_id": 83,
"nodes": [
{
"id": 54,
"type": "PreviewImage",
"pos": {
"0": 900,
"1": 157
},
"size": {
"0": 429.9277648925781,
"1": 313.20477294921875
},
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 82
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 53,
"type": "LoadImage",
"pos": {
"0": 141,
"1": 157
},
"size": {
"0": 318.50177001953125,
"1": 400.92742919921875
},
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
81
],
"slot_index": 0,
"shape": 3
},
{
"name": "MASK",
"type": "MASK",
"links": null,
"shape": 3
}
],
"properties": {
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"example.png",
"image"
]
},
{
"id": 58,
"type": "ImageCrop",
"pos": {
"0": 525,
"1": 157
},
"size": {
"0": 315,
"1": 130
},
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 81
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
82
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "ImageCrop"
},
"widgets_values": [
126,
126,
322,
196
],
"color": "#232",
"bgcolor": "#353"
}
],
"links": [
[
81,
53,
0,
58,
0,
"IMAGE"
],
[
82,
58,
0,
54,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.9090909090909091,
"offset": [
222.40137209879546,
8.659338924062864
]
}
},
"version": 0.4
}
ImageRotate ノード
画像を90度 / 180度 / 270度 回転させます。

{
"id": "3c344b31-2cca-43a0-acc2-33295e766391",
"revision": 0,
"last_node_id": 8,
"last_link_id": 2,
"nodes": [
{
"id": 1,
"type": "LoadImage",
"pos": [
1804.466796875,
382.6131591796875
],
"size": [
269.2518615722656,
346.83184814453125
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
1
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.44",
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"example.png",
"image"
]
},
{
"id": 3,
"type": "PreviewImage",
"pos": [
2371.87158203125,
382.6131591796875
],
"size": [
290.6402893066406,
331.94219970703125
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 2
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.44",
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 2,
"type": "ImageRotate",
"pos": [
2117.247314453125,
382.6131591796875
],
"size": [
211.09579467773438,
58
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 1
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
2
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.44",
"Node name for S&R": "ImageRotate"
},
"widgets_values": [
"90 degrees"
],
"color": "#232",
"bgcolor": "#353"
}
],
"links": [
[
1,
1,
0,
2,
0,
"IMAGE"
],
[
2,
2,
0,
3,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 1.035579600000038,
"offset": [
-1704.466796875,
-282.6131591796875
]
},
"frontendVersion": "1.24.0",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
ImageFlip ノード
画像を水平 / 垂直方向に反転させます。

{
"id": "3c344b31-2cca-43a0-acc2-33295e766391",
"revision": 0,
"last_node_id": 10,
"last_link_id": 4,
"nodes": [
{
"id": 1,
"type": "LoadImage",
"pos": [
1804.466796875,
382.6131591796875
],
"size": [
269.2518615722656,
346.83184814453125
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
3
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.44",
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"example.png",
"image"
]
},
{
"id": 10,
"type": "ImageFlip",
"pos": [
2115.31591796875,
382.6131591796875
],
"size": [
250.68714904785156,
58
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 3
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
4
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.44",
"Node name for S&R": "ImageFlip"
},
"widgets_values": [
"x-axis: vertically"
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 3,
"type": "PreviewImage",
"pos": [
2407.600341796875,
382.6131591796875
],
"size": [
290.6402893066406,
331.94219970703125
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 4
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.44",
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
}
],
"links": [
[
3,
1,
0,
10,
0,
"IMAGE"
],
[
4,
10,
0,
3,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 1.035579600000038,
"offset": [
-1704.466796875,
-282.6131591796875
]
},
"frontendVersion": "1.24.0",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
Resize Image v2 ノード
これは kijai/ComfyUI-KJNodes に含まれるノードです。
上記のリサイズ・クロップ・パディングが一つにまとめられたようなノードです。
| パラメータ名 | 説明 |
|---|---|
| width / height | 目標とする幅と高さ(0なら変更なし) |
| upscale_method | リサイズ時の補間方法(nearest, bilinearなど) |
| keep_proportion | stretch, pad, crop, etc. |
| pad_color | パディング時の色(RGB) |
| crop_position | center, top, bottom, left, right |
| divisible_by | この値の倍数の解像度にリサイズされます(例:32, 64) |
以前は、縦横を N の倍数 になるようにリサイズする用途で多用していましたが、現在はコアノードで対応できるため、あまり使用していません。
少し応用
これまでのノードを組み合わせて、少し複雑な画像加工をしてみましょう。
画像を半分にクロップ

{
"id": "4868028c-000b-496e-b4e0-958cdd175f4a",
"revision": 0,
"last_node_id": 63,
"last_link_id": 89,
"nodes": [
{
"id": 53,
"type": "LoadImage",
"pos": [
73.72727272727276,
158.8181818181818
],
"size": [
318.5017680965466,
400.92742544483326
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"slot_index": 0,
"links": [
84,
88
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.71",
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"example.png",
"image"
]
},
{
"id": 62,
"type": "ImageCrop",
"pos": [
931.9558227064256,
158.8181818181818
],
"size": [
270,
130
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 88
},
{
"name": "width",
"type": "INT",
"widget": {
"name": "width"
},
"link": 86
},
{
"name": "height",
"type": "INT",
"widget": {
"name": "height"
},
"link": 87
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
89
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.71",
"Node name for S&R": "ImageCrop"
},
"widgets_values": [
512,
512,
0,
0
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 61,
"type": "SimpleMath+",
"pos": [
682.0468954122235,
245.45250567287064
],
"size": [
210,
78
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "a",
"shape": 7,
"type": "INT,FLOAT",
"link": 85
},
{
"name": "b",
"shape": 7,
"type": "INT,FLOAT",
"link": null
}
],
"outputs": [
{
"name": "INT",
"type": "INT",
"links": [
86
]
},
{
"name": "FLOAT",
"type": "FLOAT",
"links": null
}
],
"properties": {
"cnr_id": "comfyui_essentials",
"ver": "1.1.0",
"Node name for S&R": "SimpleMath+"
},
"widgets_values": [
"a / 2"
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 60,
"type": "GetImageSize",
"pos": [
432.13796811802143,
246.82201179564242
],
"size": [
210,
136
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 84
}
],
"outputs": [
{
"name": "width",
"type": "INT",
"links": [
85
]
},
{
"name": "height",
"type": "INT",
"links": [
87
]
},
{
"name": "batch_size",
"type": "INT",
"links": null
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.71",
"Node name for S&R": "GetImageSize"
},
"widgets_values": [
"width: 768, height: 768\n batch size: 1"
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 63,
"type": "PreviewImage",
"pos": [
1241.8647500006277,
158.8181818181818
],
"size": [
225.18399999999997,
371.114
],
"flags": {},
"order": 4,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 89
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.71",
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
}
],
"links": [
[
84,
53,
0,
60,
0,
"IMAGE"
],
[
85,
60,
0,
61,
0,
"INT,FLOAT"
],
[
86,
61,
0,
62,
1,
"INT"
],
[
87,
60,
1,
62,
2,
"INT"
],
[
88,
53,
0,
62,
0,
"IMAGE"
],
[
89,
62,
0,
63,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.7513148009015778,
"offset": [
94.15372727272724,
67.6268181818182
]
},
"frontendVersion": "1.30.6",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
- 画像のサイズを取得
Simple mathノードで幅の半分の長さを計算ImageCropノードに計算した幅を入力し、半分にクロップ