Image Flip & Rotate
Flip images horizontally or vertically and rotate by 90°, 180°, or 270° — all in your browser.
About this tool
Image Flip & Rotate lets you mirror an image horizontally or vertically and turn it by 90, 180, or 270 degrees, all directly in your browser. It solves a small but common annoyance: quickly straightening a sideways or mirrored photo without opening a full photo editor.
To use it, upload an image, apply the flip and rotation you need, and download the corrected file. It is handy for fixing phone photos taken at an angle, mirroring graphics to fit a layout, or reorienting scanned documents.
One useful detail: the rotations are lossless quarter-turns, so your image quality is fully preserved. All processing happens locally in the browser, and your image is never uploaded to any server.
Frequently Asked Questions
Code Implementation
# Flip and rotate images with Pillow
# pip install Pillow
from PIL import Image
import os
def flip_and_rotate(input_path: str, output_path: str,
flip_horizontal: bool = False,
flip_vertical: bool = False,
rotate_degrees: float = 0,
expand: bool = True,
fill_color: tuple = (255, 255, 255)) -> None:
"""
Flip and/or rotate an image.
rotate_degrees: Positive = counter-clockwise, Negative = clockwise.
expand: If True, expand the canvas to fit rotated content (no cropping).
fill_color: Background color for empty areas after arbitrary rotation.
"""
img = Image.open(input_path)
# Horizontal flip (left-right mirror)
if flip_horizontal:
img = img.transpose(Image.FLIP_LEFT_RIGHT)
# Vertical flip (top-bottom mirror)
if flip_vertical:
img = img.transpose(Image.FLIP_TOP_BOTTOM)
# Rotate — Pillow rotates counter-clockwise by default
if rotate_degrees != 0:
if rotate_degrees % 90 == 0:
# Lossless 90/180/270 degree rotation
img = img.rotate(rotate_degrees, expand=True)
else:
# Arbitrary angle — needs expand + fill
img = img.rotate(
rotate_degrees,
expand=expand,
fillcolor=fill_color,
resample=Image.BICUBIC,
)
img.save(output_path)
print(f"Saved: {output_path} ({img.size})")
# Examples
flip_and_rotate("photo.jpg", "flipped_h.jpg", flip_horizontal=True)
flip_and_rotate("photo.jpg", "flipped_v.jpg", flip_vertical=True)
flip_and_rotate("photo.jpg", "rotated_90.jpg", rotate_degrees=90)
flip_and_rotate("photo.jpg", "rotated_180.jpg", rotate_degrees=180)
flip_and_rotate("photo.jpg", "rotated_270.jpg", rotate_degrees=270)
flip_and_rotate("photo.jpg", "rotated_15.jpg", rotate_degrees=15, fill_color=(255, 255, 255))
# Fix a photo taken sideways (clockwise) using EXIF orientation
from PIL import ImageOps
def auto_orient(input_path: str, output_path: str) -> None:
"""Rotate image to match EXIF orientation tag, then strip EXIF."""
img = Image.open(input_path)
img = ImageOps.exif_transpose(img) # Auto-rotate based on EXIF tag
img.save(output_path)
print("Auto-oriented and saved:", output_path)
auto_orient("sideways_photo.jpg", "corrected.jpg")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.