Image Resizing and Cropping
It may seem like a simple task of enlarging an image or cropping it to a square, but it is a very important process in image generation.
- Model's Optimal Resolution: Models have a "resolution where they perform best".
- Saving VRAM: If you inadvertently load and process a 4K image, you will instantly run "Out of memory".
- Unifying Materials: In image compositing, etc., it is necessary to align the sizes of multiple materials.
Since this is a frequently used task, let's firmly understand the differences between each node.
Resize
Upscale Image Node

{
"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
}
Forcibly changes the resolution to the specified width and height.
- Aspect Ratio: If you specify a ratio different from the original image, the image will be distorted.
- crop: If set to
center, it will maintain the center and crop (discard) the protruding parts instead of distorting.
Upscale Image By Node

{
"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
}
Specifies the size by magnification, such as "1.5x" or "0.5x". The aspect ratio is maintained.
ImageScaleToMaxDimension Node

{
"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
}
Resizes the image so that the long side becomes the set size, maintaining the aspect ratio. (Example: Whether it is a portrait or landscape image, make the longer side 1024px)
Scale Image to Total Pixels Node

{
"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
}
Resizes the image to the specified total number of pixels while maintaining the aspect ratio.
This is a slightly important process
Image generation models are trained with images of specific resolutions and various aspect ratios. For the model to perform at its best, it is important to generate images at a size (total number of pixels) similar to when it was trained.
Using this node, you can adjust the image by specifying the total number of pixels while maintaining the original composition. Convenient!
Commonly Used Values (Megapixels)
| Target Size | Total Pixels | Setting Value (megapixels) |
|---|---|---|
| 512 × 512 | 262,144 | 0.25 |
| 768 × 768 | 589,824 | 0.56 |
| 1024 × 1024 | 1,048,576 | 1.00 (Recommended for SDXL) |
| 1536 × 1536 | 2,359,296 | 2.25 |
Padding
Padding is the process of adjusting the size by adding margins (black bars, etc.) around the image.
Depending on the node, this margin part can be output as a mask, so it is used as preparation for Outpainting.
ResizeAndPadImage Node

{
"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
}
Resizes to the specified resolution and fills the missing parts with padding.
Since it cannot output as a mask, there may be few occasions to use it.
Pad Image for Outpainting Node

{
"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
}
Adds margins of the specified number of pixels to the top, bottom, left, and right of the image.
The margin part is output as a mask.
- feathering: Blurs the boundary between the margin and the image. Affects only the mask.
Crop and Other Edit Operations
ImageCrop Node

{
"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
}
- Crops a part of the image in a rectangle by specifying x, y coordinates and width/height.
ImageRotate Node

{
"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
}
- Rotates the image by 90 / 180 / 270 degrees.
ImageFlip Node

{
"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
}
- Flips the image horizontally / vertically.
Resize Image v2 Node
This is a node included in kijai/ComfyUI-KJNodes.
It is like a node that combines the above resize, crop, and padding into one.
Other than that, as an important process, it can resize the image to a resolution that is a multiple of N.
| Parameter Name | Description |
|---|---|
| width / height | Target width and height (no change if 0) |
| upscale_method | Interpolation method during resizing (nearest, bilinear, etc.) |
| keep_proportion | stretch, pad, crop, etc. |
| pad_color | Color for padding (RGB) |
| crop_position | center, top, bottom, left, right |
| divisible_by | Resizes to a resolution that is a multiple of this value (e.g., 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
}
Settings to just resize the image to a resolution that is a multiple of 32.
divisible_by: Resizes to a resolution that is a multiple of this value.- If you simply want to perform this operation, set other parameters to 0.
Why is this operation important?
It involves something called VAE. I will explain in detail in Why can only resolutions that are multiples of 8 be generated?, but anyway, generative AI cannot generate images with subtle resolutions.
Basically, ComfyUI crops automatically internally, so there is no need to use this node, but it is used when an error occurs if it is not the specified resolution, or when you want to perfectly match the pixels of the input image and the output image.
Getting Image Information
Get Image Size Node

{
"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
}
- Outputs the width and height of the image as numerical values.
- If you connect the obtained size to
Upscale Image, you can match another image to "exactly the same size". - *In the latest version, batch size (number of sheets) can also be obtained.
A Little Application
Let's try some slightly complex image processing by combining the nodes so far.
Crop Image to Half

{
"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
}
- Get the size of the image
- Calculate half the width with
Simple mathnode - Input the calculated width to
ImageCropnode and crop to half