@@ -583,6 +583,49 @@ def get_size(self, image, unique_id=None) -> tuple[int, int]:
583
583
584
584
return width , height , batch_size
585
585
586
+ class ImageRotate :
587
+ @classmethod
588
+ def INPUT_TYPES (s ):
589
+ return {"required" : { "image" : (IO .IMAGE ,),
590
+ "rotation" : (["none" , "90 degrees" , "180 degrees" , "270 degrees" ],),
591
+ }}
592
+ RETURN_TYPES = (IO .IMAGE ,)
593
+ FUNCTION = "rotate"
594
+
595
+ CATEGORY = "image/transform"
596
+
597
+ def rotate (self , image , rotation ):
598
+ rotate_by = 0
599
+ if rotation .startswith ("90" ):
600
+ rotate_by = 1
601
+ elif rotation .startswith ("180" ):
602
+ rotate_by = 2
603
+ elif rotation .startswith ("270" ):
604
+ rotate_by = 3
605
+
606
+ image = torch .rot90 (image , k = rotate_by , dims = [2 , 1 ])
607
+ return (image ,)
608
+
609
+ class ImageFlip :
610
+ @classmethod
611
+ def INPUT_TYPES (s ):
612
+ return {"required" : { "image" : (IO .IMAGE ,),
613
+ "flip_method" : (["x-axis: vertically" , "y-axis: horizontally" ],),
614
+ }}
615
+ RETURN_TYPES = (IO .IMAGE ,)
616
+ FUNCTION = "flip"
617
+
618
+ CATEGORY = "image/transform"
619
+
620
+ def flip (self , image , flip_method ):
621
+ if flip_method .startswith ("x" ):
622
+ image = torch .flip (image , dims = [1 ])
623
+ elif flip_method .startswith ("y" ):
624
+ image = torch .flip (image , dims = [2 ])
625
+
626
+ return (image ,)
627
+
628
+
586
629
NODE_CLASS_MAPPINGS = {
587
630
"ImageCrop" : ImageCrop ,
588
631
"RepeatImageBatch" : RepeatImageBatch ,
@@ -594,4 +637,6 @@ def get_size(self, image, unique_id=None) -> tuple[int, int]:
594
637
"ImageStitch" : ImageStitch ,
595
638
"ResizeAndPadImage" : ResizeAndPadImage ,
596
639
"GetImageSize" : GetImageSize ,
640
+ "ImageRotate" : ImageRotate ,
641
+ "ImageFlip" : ImageFlip ,
597
642
}
0 commit comments