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

{
"id": "4868028c-000b-496e-b4e0-958cdd175f4a",
"revision": 0,
"last_node_id": 59,
"last_link_id": 82,
"nodes": [
{
"id": 54,
"type": "PreviewImage",
"pos": [
900,
157
],
"size": [
429.92777495151813,
313.2047839407444
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 78
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.71",
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 53,
"type": "LoadImage",
"pos": [
141,
157
],
"size": [
318.5017680965466,
400.92742544483326
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"slot_index": 0,
"links": [
77,
79
]
},
{
"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": 52,
"type": "ImageScale",
"pos": [
521,
157
],
"size": [
315,
130
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 77
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"slot_index": 0,
"links": [
78
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.71",
"Node name for S&R": "ImageScale"
},
"widgets_values": [
"nearest-exact",
768,
480,
"disabled"
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 55,
"type": "ImageScale",
"pos": [
521,
541
],
"size": [
315,
130
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 79
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"slot_index": 0,
"links": [
82
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.71",
"Node name for S&R": "ImageScale"
},
"widgets_values": [
"nearest-exact",
768,
480,
"center"
],
"color": "#323",
"bgcolor": "#535"
},
{
"id": 59,
"type": "PreviewImage",
"pos": [
900,
541
],
"size": [
446.1300000000001,
311.21900000000016
],
"flags": {},
"order": 4,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 82
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.71",
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
}
],
"links": [
[
77,
53,
0,
52,
0,
"IMAGE"
],
[
78,
52,
0,
54,
0,
"IMAGE"
],
[
79,
53,
0,
55,
0,
"IMAGE"
],
[
82,
55,
0,
59,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.683013455365071,
"offset": [
67.34339999999997,
51.34339999999996
]
},
"frontendVersion": "1.30.6",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
- アスペクト比: 元画像と異なる比率を指定すると、画像が歪みます。
- crop:
centerに設定すると、歪ませる代わりに中心を維持してはみ出た部分をクロップ(切り捨て)します。
Upscale Image By ノード
「1.5倍」「0.5倍」のように、倍率でサイズを指定します。アスペクト比は維持されます。

{
"last_node_id": 59,
"last_link_id": 85,
"nodes": [
{
"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": [
84
],
"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": 59,
"type": "ImageScaleBy",
"pos": {
"0": 522.2508544921875,
"1": 157
},
"size": {
"0": 315,
"1": 82
},
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 84
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
85
],
"shape": 3,
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "ImageScaleBy"
},
"widgets_values": [
"nearest-exact",
1.5
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 54,
"type": "PreviewImage",
"pos": {
"0": 900,
"1": 157
},
"size": [
567.1885245612689,
593.7392258993473
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 85
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
}
],
"links": [
[
84,
53,
0,
59,
0,
"IMAGE"
],
[
85,
59,
0,
54,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.8264462809917354,
"offset": [
174.7814754387315,
91.19389910065289
]
}
},
"version": 0.4
}
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
}
Scale Image to Total Pixels ノード
指定した 総ピクセル数(画素数) になるように、アスペクト比を保ったままリサイズします。

{
"id": "33455268-9381-48c0-8439-43e07b8c239c",
"revision": 0,
"last_node_id": 4,
"last_link_id": 2,
"nodes": [
{
"id": 3,
"type": "ImageScaleToTotalPixels",
"pos": [
-116.21300506591797,
39.75439453125
],
"size": [
270,
82
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 2
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
1
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.41",
"Node name for S&R": "ImageScaleToTotalPixels"
},
"widgets_values": [
"nearest-exact",
1.0000000000000002
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 2,
"type": "PreviewImage",
"pos": [
208.1898651123047,
39.75439453125
],
"size": [
463.2727355957031,
500
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 1
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.41",
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 1,
"type": "LoadImage",
"pos": [
-453.8507995605469,
39.75439453125
],
"size": [
283.23492431640625,
380.89422607421875
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
2
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.41",
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"example.png",
"image"
]
}
],
"links": [
[
1,
3,
0,
2,
0,
"IMAGE"
],
[
2,
1,
0,
3,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.8264462809917356,
"offset": [
999.130799560547,
227.22560546874996
]
},
"frontendVersion": "1.23.2",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
すこし重要な処理です
画像生成モデルは、特定の解像度と様々なアスペクト比の画像で学習されています。モデルが最高の性能を発揮するためには、学習時と同じようなサイズ(総ピクセル数)で画像を生成することが重要です。
このノードを使用すると、元の構図を維持したまま、総ピクセル数を指定して画像を調整できます。便利!
よく使う値(メガピクセル)
| 目標サイズ | 総ピクセル数 | 設定値 (megapixels) |
|---|---|---|
| 512 × 512 | 262,144 | 0.25 |
| 768 × 768 | 589,824 | 0.56 |
| 1024 × 1024 | 1,048,576 | 1.00 (SDXL推奨) |
| 1536 × 1536 | 2,359,296 | 2.25 |
パディング
パディングとは、画像の周囲に余白(黒帯など)を追加して、サイズを調整する処理のことです。
ノードによっては、この余白部分をマスクとして出力できるため、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 に含まれるノードです。
上記のリサイズ・クロップ・パディングが一つにまとめられたようなノードです。
それ以外に重要な処理として、画像をNの倍数の解像度にリサイズすることができます。
| パラメータ名 | 説明 |
|---|---|
| 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) |

{
"id": "4868028c-000b-496e-b4e0-958cdd175f4a",
"revision": 0,
"last_node_id": 65,
"last_link_id": 92,
"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": [
91
]
},
{
"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": 65,
"type": "PreviewImage",
"pos": [
780.227181818181,
158.8181818181818
],
"size": [
394.5454545454543,
443.52066115702473
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 92
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.71",
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 64,
"type": "ImageResizeKJv2",
"pos": [
451.22811132100014,
158.8181818181818
],
"size": [
270,
336
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 91
},
{
"name": "mask",
"shape": 7,
"type": "MASK",
"link": null
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
92
]
},
{
"name": "width",
"type": "INT",
"links": null
},
{
"name": "height",
"type": "INT",
"links": null
},
{
"name": "mask",
"type": "MASK",
"links": null
}
],
"properties": {
"cnr_id": "comfyui-kjnodes",
"ver": "c661baadd9683c0033cd2a6ad90157c6d099a6c2",
"Node name for S&R": "ImageResizeKJv2"
},
"widgets_values": [
0,
0,
"nearest-exact",
"crop",
"0, 0, 0",
"center",
8,
"cpu",
"<tr><td>Output: </td><td><b>1</b> x <b>768</b> x <b>768 | 6.75MB</b></td></tr>"
],
"color": "#232",
"bgcolor": "#353"
}
],
"links": [
[
91,
53,
0,
64,
0,
"IMAGE"
],
[
92,
64,
0,
65,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.8264462809917354,
"offset": [
26.272727272727238,
-58.81818181818181
]
},
"frontendVersion": "1.30.6",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
画像を32の倍数の解像度にリサイズするだけの設定です。
divisible_by: この値の倍数の解像度にリサイズされます- 単にこの操作だけしたい場合は、他のパラメータは0にします。
なぜこの操作が重要なのか?
というと、VAEというものに関わってきます。詳しくは8の倍数の解像度しか生成できないのはなぜ?で解説しますが、ともかく、生成AIは微妙な解像度の画像を生成することが出来ません。
基本的に、ComfyUIは内部で自動でクロップするため、このノードを使う必要は無いのですが、指定解像度でないとエラーが出たり、入力した画像と出力した画像のピクセルを完璧に合わせたいときなどに使用することがあります。
画像情報の取得
Get Image Size ノード
画像の幅(width)と高さ(height)、バッチサイズ(枚数)を数値として出力します。

{
"id": "c4311028-f464-4d21-a079-ea6457b21328",
"revision": 0,
"last_node_id": 11,
"last_link_id": 13,
"nodes": [
{
"id": 5,
"type": "LoadImage",
"pos": [
1429.7952880859375,
565.1294555664062
],
"size": [
276.28009033203125,
554.1300048828125
],
"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.36",
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"スバルダック.png",
"image"
]
},
{
"id": 8,
"type": "PreviewImage",
"pos": [
2414.51318359375,
565.1294555664062
],
"size": [
301.70001220703125,
395.6000061035156
],
"flags": {},
"order": 4,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 8
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.36",
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 2,
"type": "LoadImage",
"pos": [
1429.7952880859375,
120.70742797851562
],
"size": [
276.28009033203125,
393.20001220703125
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
9
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.36",
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"example.png",
"image"
]
},
{
"id": 10,
"type": "GetImageSize",
"pos": [
1754.6292724609375,
120.70742797851562
],
"size": [
210,
116
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 9
}
],
"outputs": [
{
"name": "width",
"type": "INT",
"links": [
12
]
},
{
"name": "height",
"type": "INT",
"links": [
13
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.39",
"Node name for S&R": "GetImageSize"
},
"widgets_values": [
"width: 768, height: 768"
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 7,
"type": "ImageScale",
"pos": [
2096.332275390625,
565.1294555664062
],
"size": [
270,
130
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 5
},
{
"name": "width",
"type": "INT",
"widget": {
"name": "width"
},
"link": 12
},
{
"name": "height",
"type": "INT",
"widget": {
"name": "height"
},
"link": 13
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
8
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.36",
"Node name for S&R": "ImageScale"
},
"widgets_values": [
"nearest-exact",
512,
512,
"center"
],
"color": "#323",
"bgcolor": "#535"
}
],
"links": [
[
5,
5,
0,
7,
0,
"IMAGE"
],
[
8,
7,
0,
8,
0,
"IMAGE"
],
[
9,
2,
0,
10,
0,
"IMAGE"
],
[
12,
10,
0,
7,
1,
"INT"
],
[
13,
10,
1,
7,
2,
"INT"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.9090909090909091,
"offset": [
-1329.7952880859375,
-20.707427978515625
]
},
"frontendVersion": "1.22.0",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
- 取得したサイズを
Upscale Imageに繋げば、別の画像を「全く同じサイズ」にすることができます。- 非常によく使う処理です。
少し応用
これまでのノードを組み合わせて、少し複雑な画像加工をしてみましょう
画像を半分にクロップ

{
"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ノードに計算した幅を入力し、半分にクロップ