88
99
1010# Model-specific resolution presets with constraints
11+ # Includes: model-optimized sizes + photo print (4x6, 5x7, 8x10) + digital/social + canvas art ratios
1112MODEL_RESOLUTIONS = {
1213 "Flux" : {
13- "square" : [(512 , 512 ), (768 , 768 ), (1024 , 1024 ), (1280 , 1280 ), (1536 , 1536 ), (1920 , 1920 ), (2048 , 2048 )],
14- "portrait" : [(768 , 1344 ), (832 , 1216 ), (896 , 1152 ), (928 , 1664 ), (1024 , 1536 ), (1024 , 1792 ), (1080 , 1920 ), (1152 , 2048 )],
15- "landscape" : [(1344 , 768 ), (1216 , 832 ), (1152 , 896 ), (1536 , 1024 ), (1664 , 928 ), (1792 , 1024 ), (1920 , 1080 ), (2048 , 1152 )],
14+ "square" : [(512 , 512 ), (768 , 768 ), (1024 , 1024 ), (1088 , 1088 ), ( 1280 , 1280 ), (1536 , 1536 ), (1920 , 1920 ), (2048 , 2048 )],
15+ "portrait" : [(688 , 2048 ), ( 768 , 1344 ), (832 , 1216 ), (896 , 1152 ), (928 , 1664 ), (1024 , 1536 ), (1024 , 1792 ), (1024 , 2048 ), ( 1088 , 1920 ), (1152 , 2048 ), ( 1200 , 1792 ), ( 1360 , 2048 ), ( 1456 , 2048 ), ( 1536 , 2048 ), ( 1616 , 2048 ), ( 1632 , 2048 ), ( 1712 , 2048 )],
16+ "landscape" : [(1280 , 720 ), ( 1344 , 768 ), (1216 , 832 ), (1152 , 896 ), (1536 , 1024 ), (1664 , 928 ), (1792 , 1024 ), (1792 , 1200 ), ( 1920 , 1088 ), (2048 , 688 ), ( 2048 , 1024 ), ( 2048 , 1152 ), ( 2048 , 1360 ), ( 2048 , 1456 ), ( 2048 , 1536 ), ( 2048 , 1616 ), ( 2048 , 1632 ), ( 2048 , 1712 )],
1617 "constraints" : {"divisible_by" : 16 , "min" : 256 , "max" : 2048 }
1718 },
1819 "Qwen Image" : {
19- "square" : [(1024 , 1024 ), (1280 , 1280 ), (1328 , 1328 ), (1536 , 1536 ), (1920 , 1920 ), (2048 , 2048 )],
20- "portrait" : [(928 , 1664 ), (1024 , 1536 ), (1080 , 1920 ), (1140 , 1472 ), (1152 , 2048 )],
21- "landscape" : [(1472 , 1140 ), (1536 , 1024 ), (1664 , 928 ), (1920 , 1080 ), (2048 , 1152 )],
20+ "square" : [(1024 , 1024 ), (1080 , 1080 ), ( 1280 , 1280 ), (1328 , 1328 ), (1536 , 1536 ), (1920 , 1920 ), (2048 , 2048 )],
21+ "portrait" : [(680 , 2048 ), ( 928 , 1664 ), (1024 , 1536 ), (1024 , 2048 ), ( 1080 , 1920 ), (1140 , 1472 ), (1152 , 2048 ), ( 1200 , 1800 ), ( 1368 , 2048 ), ( 1464 , 2048 ), ( 1536 , 2048 ), ( 1608 , 2048 ), ( 1640 , 2048 ), ( 1704 , 2048 )],
22+ "landscape" : [(1280 , 720 ), ( 1472 , 1140 ), (1536 , 1024 ), (1664 , 928 ), (1800 , 1200 ), ( 1920 , 1080 ), (2048 , 680 ), ( 2048 , 1024 ), ( 2048 , 1152 ), ( 2048 , 1368 ), ( 2048 , 1464 ), ( 2048 , 1536 ), ( 2048 , 1608 ), ( 2048 , 1640 ), ( 2048 , 1704 )],
2223 "constraints" : {"divisible_by" : 8 , "min" : 256 , "max" : 2048 }
2324 },
2425 "Z-Image" : {
25- "square" : [(512 , 512 ), (768 , 768 ), (1024 , 1024 ), (1280 , 1280 ), (1536 , 1536 ), (1920 , 1920 ), (2048 , 2048 )],
26- "portrait" : [(720 , 1280 ), (768 , 1024 ), (1080 , 1920 ), (1152 , 2048 )],
27- "landscape" : [(1024 , 768 ), (1280 , 720 ), (1920 , 1080 ), (2048 , 1152 )],
26+ "square" : [(512 , 512 ), (768 , 768 ), (1024 , 1024 ), (1080 , 1080 ), ( 1280 , 1280 ), (1536 , 1536 ), (1920 , 1920 ), (2048 , 2048 )],
27+ "portrait" : [(680 , 2048 ), ( 720 , 1280 ), (768 , 1024 ), (1024 , 2048 ), ( 1080 , 1920 ), (1152 , 2048 ), ( 1200 , 1800 ), ( 1368 , 2048 ), ( 1464 , 2048 ), ( 1536 , 2048 ), ( 1608 , 2048 ), ( 1640 , 2048 ), ( 1704 , 2048 )],
28+ "landscape" : [(1024 , 768 ), (1280 , 720 ), (1800 , 1200 ), ( 1920 , 1080 ), (2048 , 680 ), ( 2048 , 1024 ), ( 2048 , 1152 ), ( 2048 , 1368 ), ( 2048 , 1464 ), ( 2048 , 1536 ), ( 2048 , 1608 ), ( 2048 , 1640 ), ( 2048 , 1704 )],
2829 "constraints" : {"divisible_by" : 8 , "min" : 256 , "max" : 2048 }
2930 },
3031 "SD 1.5" : {
31- "square" : [(512 , 512 ), (768 , 768 ), (1024 , 1024 ), (1280 , 1280 ), (1536 , 1536 )],
32- "portrait" : [(512 , 768 ), (512 , 682 ), (512 , 1024 ), (768 , 1024 ), (768 , 1344 ), (1080 , 1920 )],
33- "landscape" : [(768 , 512 ), (1024 , 512 ), (1024 , 768 ), (1344 , 768 ), (1536 , 512 ), (1920 , 1080 )],
32+ "square" : [(512 , 512 ), (768 , 768 ), (1024 , 1024 ), (1080 , 1080 ), ( 1280 , 1280 ), (1536 , 1536 )],
33+ "portrait" : [(512 , 768 ), (512 , 682 ), (512 , 1024 ), (680 , 2048 ), ( 768 , 1024 ), (768 , 1344 ), (1024 , 2048 ), ( 1080 , 1920 ), ( 1200 , 1800 ), ( 1368 , 2048 ), ( 1464 , 2048 ), ( 1536 , 2048 ), ( 1608 , 2048 ), ( 1640 , 2048 ), ( 1704 , 2048 )],
34+ "landscape" : [(768 , 512 ), (1024 , 512 ), (1024 , 768 ), (1280 , 720 ), ( 1344 , 768 ), (1536 , 512 ), (1800 , 1200 ), ( 1920 , 1080 ), ( 2048 , 680 ), ( 2048 , 1024 ), ( 2048 , 1368 ), ( 2048 , 1464 ), ( 2048 , 1536 ), ( 2048 , 1608 ), ( 2048 , 1640 ), ( 2048 , 1704 )],
3435 "constraints" : {"divisible_by" : 8 , "min" : 256 , "max" : 2048 }
3536 },
3637 "SDXL" : {
37- "square" : [(1024 , 1024 ), (1280 , 1280 ), (1536 , 1536 ), (1920 , 1920 ), (2048 , 2048 )],
38- "portrait" : [(640 , 1536 ), (768 , 1344 ), (832 , 1216 ), (896 , 1152 ), (1024 , 1536 ), (1080 , 1920 ), (1152 , 2048 )],
39- "landscape" : [(1152 , 896 ), (1216 , 832 ), (1344 , 768 ), (1536 , 640 ), (1536 , 1024 ), (1920 , 1080 ), (2048 , 1152 )],
38+ "square" : [(1024 , 1024 ), (1080 , 1080 ), ( 1280 , 1280 ), (1536 , 1536 ), (1920 , 1920 ), (2048 , 2048 )],
39+ "portrait" : [(640 , 1536 ), (680 , 2048 ), ( 768 , 1344 ), (832 , 1216 ), (896 , 1152 ), (1024 , 1536 ), (1024 , 2048 ), ( 1080 , 1920 ), (1152 , 2048 ), ( 1200 , 1800 ), ( 1368 , 2048 ), ( 1464 , 2048 ), ( 1536 , 2048 ), ( 1608 , 2048 ), ( 1640 , 2048 ), ( 1704 , 2048 )],
40+ "landscape" : [(1152 , 896 ), (1216 , 832 ), (1280 , 720 ), ( 1344 , 768 ), (1536 , 640 ), (1536 , 1024 ), (1800 , 1200 ), ( 1920 , 1080 ), (2048 , 680 ), ( 2048 , 1024 ), ( 2048 , 1152 ), ( 2048 , 1368 ), ( 2048 , 1464 ), ( 2048 , 1536 ), ( 2048 , 1608 ), ( 2048 , 1640 ), ( 2048 , 1704 )],
4041 "constraints" : {"divisible_by" : 8 , "min" : 256 , "max" : 2048 }
4142 }
4243}
@@ -60,7 +61,7 @@ def gcd(a, b):
6061
6162def calculate_aspect_ratio (width , height ):
6263 """
63- Calculate simplified aspect ratio from dimensions, rounding to common ratios .
64+ Calculate simplified aspect ratio from dimensions, using nearest common ratio .
6465
6566 Args:
6667 width (int): Width in pixels
@@ -91,19 +92,12 @@ def calculate_aspect_ratio(width, height):
9192 (0.56 , "9:16" ), # 0.5625
9293 (0.5 , "1:2" ), # 0.5
9394 (0.42 , "5:12" ), # 0.4166...
95+ (0.33 , "1:3" ), # 0.333... (panoramic)
9496 ]
9597
96- # Find closest common ratio (within 5% tolerance)
97- tolerance = 0.05
98- for ratio_value , ratio_str in common_ratios :
99- if abs (actual_ratio - ratio_value ) / ratio_value < tolerance :
100- return ratio_str
101-
102- # If no close match, calculate GCD-based ratio
103- divisor = gcd (width , height )
104- ratio_width = width // divisor
105- ratio_height = height // divisor
106- return f"{ ratio_width } :{ ratio_height } "
98+ # Find closest common ratio by absolute difference
99+ closest_ratio = min (common_ratios , key = lambda r : abs (actual_ratio - r [0 ]))
100+ return closest_ratio [1 ]
107101
108102
109103def format_resolution (width , height ):
@@ -283,6 +277,13 @@ def INPUT_TYPES(cls):
283277 "resolution_multiplier" : (["1x" , "2x" , "3x" , "4x" ], {
284278 "default" : "1x"
285279 }),
280+ "batch_size" : ("INT" , {
281+ "default" : 1 ,
282+ "min" : 1 ,
283+ "max" : 64 ,
284+ "step" : 1 ,
285+ "display" : "number"
286+ }),
286287 },
287288 "optional" : {
288289 "custom_width" : ("INT" , {
@@ -302,6 +303,13 @@ def INPUT_TYPES(cls):
302303 "custom_multiplier" : (["1x" , "2x" , "3x" , "4x" ], {
303304 "default" : "1x"
304305 }),
306+ "custom_batch" : ("INT" , {
307+ "default" : 1 ,
308+ "min" : 1 ,
309+ "max" : 64 ,
310+ "step" : 1 ,
311+ "display" : "number"
312+ }),
305313 }
306314 }
307315
@@ -310,17 +318,19 @@ def INPUT_TYPES(cls):
310318 FUNCTION = "select_resolution"
311319 CATEGORY = "utils"
312320
313- def select_resolution (self , model , resolution , resolution_multiplier = "1x" , custom_width = 0 , custom_height = 0 , custom_multiplier = "1x" ):
321+ def select_resolution (self , model , resolution , resolution_multiplier = "1x" , batch_size = 1 , custom_width = 0 , custom_height = 0 , custom_multiplier = "1x" , custom_batch = 1 ):
314322 """
315323 Select and validate resolution, generate outputs.
316324
317325 Args:
318326 model (str): Selected model name
319327 resolution (str): Selected preset resolution string
320328 resolution_multiplier (str): Multiplier for resolution (1x-4x)
329+ batch_size (int): Number of latent samples for preset resolution (default: 1)
321330 custom_width (int, optional): Custom width override
322331 custom_height (int, optional): Custom height override
323332 custom_multiplier (str, optional): Multiplier for custom dimensions (1x-4x)
333+ custom_batch (int, optional): Number of latent samples for custom resolution (default: 1)
324334
325335 Returns:
326336 tuple: (width: int, height: int, latent: dict, custom_width: int, custom_height: int, custom_latent: dict)
@@ -336,8 +346,8 @@ def select_resolution(self, model, resolution, resolution_multiplier="1x", custo
336346 width *= multiplier
337347 height *= multiplier
338348
339- # Generate latent for preset resolution
340- latent = self ._generate_empty_latent (width , height )
349+ # Generate latent for preset resolution with batch size
350+ latent = self ._generate_empty_latent (width , height , batch_size )
341351
342352 # Determine final custom dimensions
343353 if custom_width > 0 and custom_height > 0 :
@@ -349,13 +359,13 @@ def select_resolution(self, model, resolution, resolution_multiplier="1x", custo
349359 if model != "All" :
350360 self ._validate_dimensions (model , final_custom_width , final_custom_height )
351361
352- # Generate custom latent
353- custom_latent = self ._generate_empty_latent (final_custom_width , final_custom_height )
362+ # Generate custom latent with custom batch size
363+ custom_latent = self ._generate_empty_latent (final_custom_width , final_custom_height , custom_batch )
354364
355365 return (width , height , latent , final_custom_width , final_custom_height , custom_latent )
356366 else :
357367 # No custom dimensions, return zeros and minimal empty custom latent
358- custom_latent = self ._generate_empty_latent (1 , 1 )
368+ custom_latent = self ._generate_empty_latent (1 , 1 , 1 )
359369
360370 return (width , height , latent , 0 , 0 , custom_latent )
361371
@@ -433,5 +443,5 @@ def _generate_empty_latent(self, width, height, batch_size=1):
433443}
434444
435445NODE_DISPLAY_NAME_MAPPINGS = {
436- "ResolutionSelector" : "Resolution Selector" ,
446+ "ResolutionSelector" : "Resolution Selector Plus " ,
437447}
0 commit comments