@@ -48,6 +48,25 @@ def repeat(self, image, amount):
4848 s = image .repeat ((amount , 1 ,1 ,1 ))
4949 return (s ,)
5050
51+ class ImageFromBatch :
52+ @classmethod
53+ def INPUT_TYPES (s ):
54+ return {"required" : { "image" : ("IMAGE" ,),
55+ "batch_index" : ("INT" , {"default" : 0 , "min" : 0 , "max" : 63 }),
56+ "length" : ("INT" , {"default" : 1 , "min" : 1 , "max" : 64 }),
57+ }}
58+ RETURN_TYPES = ("IMAGE" ,)
59+ FUNCTION = "frombatch"
60+
61+ CATEGORY = "image/batch"
62+
63+ def frombatch (self , image , batch_index , length ):
64+ s_in = image
65+ batch_index = min (s_in .shape [0 ] - 1 , batch_index )
66+ length = min (s_in .shape [0 ] - batch_index , length )
67+ s = s_in [batch_index :batch_index + length ].clone ()
68+ return (s ,)
69+
5170class SaveAnimatedWEBP :
5271 def __init__ (self ):
5372 self .output_dir = folder_paths .get_output_directory ()
@@ -170,6 +189,7 @@ def save_images(self, images, fps, compress_level, filename_prefix="ComfyUI", pr
170189NODE_CLASS_MAPPINGS = {
171190 "ImageCrop" : ImageCrop ,
172191 "RepeatImageBatch" : RepeatImageBatch ,
192+ "ImageFromBatch" : ImageFromBatch ,
173193 "SaveAnimatedWEBP" : SaveAnimatedWEBP ,
174194 "SaveAnimatedPNG" : SaveAnimatedPNG ,
175195}
0 commit comments