Sunday, May 03, 2026

Image Flip to use on nemo

 

code in python for flip horizontal images:

from PIL import Image
import os
import sys

def flip_horizontal(input_path):
    # Split filename and extension
    base, ext = os.path.splitext(input_path)
    
    # Create output filename
    output_path = f"{base}_flipped{ext}"
    
    # Open image
    with Image.open(input_path) as img:
        # Flip horizontally
        flipped = img.transpose(Image.FLIP_LEFT_RIGHT)
        
        # Save result
        flipped.save(output_path)
    
    return output_path


# Example usage
if __name__ == "__main__":
    
    if len(sys.argv) < 2:
        print("No input files provided.")
        sys.exit(1)

    for input_image in sys.argv[1:]:
        try:
            output_image = flip_horizontal(input_image)
            print(f"Saved: {output_image}")
        except Exception as e:
            print(f"Error processing {input_image}: {e}")

No comments:

Image Flip to use on nemo

  code in python for flip horizontal images: from PIL import Image import os import sys def flip_horizontal(input_path):     # Split filenam...