Rotate
Rotate images by any angle clockwise or counter-clockwise with customizable background color for empty areas.
Installation
To install the Image plugin:
Usage
Basic Usage
Options
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
--angle <degrees> | -a | number | 90 | Rotation angle in degrees |
--background <color> | string | transparent | Background color for empty areas | |
--output <path> | -o | string | <input>-rotated.<ext> | Output file path |
--quality <quality> | -q | number | 90 | Output quality (1-100) |
--dry-run | boolean | false | Preview without making changes | |
--verbose | -v | boolean | false | Show detailed output |
--help | boolean | false | Display help information |
Rotation Angles
Positive Angles (Clockwise)
- 90°: Quarter turn right (portrait → landscape)
- 180°: Half turn (upside down)
- 270°: Three-quarter turn right (same as -90°)
- 45°, 30°, etc.: Custom angles
Negative Angles (Counter-Clockwise)
- -90°: Quarter turn left (landscape → portrait)
- -180°: Half turn (same as 180°)
- -45°, -30°, etc.: Custom angles
Common Angles
Background Colors
When rotating by non-90° angles, empty corners appear. Specify background color:
Transparent (Default)
# PNG with transparency
mediaproc image rotate logo.png -a 45 --background transparent
Named Colors
# White background
mediaproc image rotate photo.jpg -a 30 --background white
# Black background
mediaproc image rotate image.png -a 45 --background black
# Red background
mediaproc image rotate photo.jpg -a 15 --background red
Hex Colors
# Custom hex color
mediaproc image rotate photo.jpg -a 45 --background "#f0f0f0"
# RGB color
mediaproc image rotate image.png -a 30 --background "rgb(240, 240, 240)"
Examples
1. Default Rotation
Rotate 90° clockwise:
mediaproc image rotate photo.jpg
Result: Portrait becomes landscape, landscape becomes portrait.
2. Counter-Clockwise Rotation
Rotate 90° counter-clockwise:
mediaproc image rotate image.png -a -90
Use: Fix orientation, create vertical layout.
3. Upside Down
Rotate 180°:
mediaproc image rotate photo.jpg -a 180
Effect: Complete flip (upside down).
4. Slight Tilt
Subtle 5° tilt for artistic effect:
mediaproc image rotate photo.jpg -a 5 --background white
Creative: Dynamic composition.
5. Diagonal Tilt
45° angle:
mediaproc image rotate image.png -a 45 --background transparent
Artistic: Diamond orientation.
6. Batch Rotation
Rotate multiple images:
mediaproc image rotate "photos/*.jpg" -a 90
Batch: All images rotated same angle.
7. Fix Camera Orientation
Correct sideways photo:
mediaproc image rotate sideways.jpg -a 90 -o corrected.jpg
Photography: Fix incorrectly rotated photos.
8. Create Vertical Banner
Rotate landscape to portrait:
mediaproc image rotate banner.jpg -a 90 -o vertical-banner.jpg
Web Design: Vertical layouts.
9. Custom Background
Rotate with matching background:
mediaproc image rotate photo.jpg -a 30 --background "#e8e8e8"
Design: Match document background.
10. High Quality Output
Maximum quality rotation:
mediaproc image rotate image.jpg -a 45 -q 100 --background white
Print: No quality loss.
11. Verbose Output
Show processing details:
mediaproc image rotate photo.jpg -a 90 --verbose
Info: Original size, processing time.
12. Preview Operation
Check before rotating:
mediaproc image rotate image.jpg -a 45 --dry-run
Safety: Verify settings.
13. Multiple Rotations
Different angles for comparison:
# Slight tilt
mediaproc image rotate photo.jpg -a 5 -o tilt-5.jpg
# Moderate tilt
mediaproc image rotate photo.jpg -a 15 -o tilt-15.jpg
# Strong tilt
mediaproc image rotate photo.jpg -a 30 -o tilt-30.jpg
Comparison: Test different angles.
14. Rotate Scanned Document
Straighten scanned page:
mediaproc image rotate scan.jpg -a 2 --background white
Documents: Minor corrections.
15. Create Rotated Collage Element
Rotate for collage composition:
mediaproc image rotate element.png -a -15 --background transparent
Design: Dynamic collage elements.
Use Cases
1. Fix Image Orientation
Correct camera rotation:
# Portrait taken in landscape mode
mediaproc image rotate portrait.jpg -a 90
# Upside down photo
mediaproc image rotate photo.jpg -a 180
Photography: Fix incorrect orientation.
2. Create Artistic Tilts
Dynamic compositions:
# Slight tilt for interest
mediaproc image rotate photo.jpg -a 5 --background white
# Dramatic angle
mediaproc image rotate image.jpg -a 30 --background black
Art: Add visual interest.
3. Document Scanning
Straighten scanned documents:
# Minor rotation correction
mediaproc image rotate scan.jpg -a -2 --background white
# Fix sideways scan
mediaproc image rotate document.jpg -a 90
Documents: Correct scanner issues.
4. Social Media
Rotate for platform requirements:
# Instagram portrait
mediaproc image rotate landscape.jpg -a 90
# Vertical story format
mediaproc image rotate horizontal.jpg -a 90
Social: Platform-specific formats.
5. Logo Variations
Create rotated logo versions:
# Rotated logo
mediaproc image rotate logo.png -a 45 --background transparent
# Inverted logo
mediaproc image rotate logo.png -a 180
Branding: Logo variations.
6. Web Design
Rotate elements for layouts:
# Rotated header element
mediaproc image rotate element.png -a 15 --background transparent
# Vertical sidebar graphic
mediaproc image rotate graphic.jpg -a 90
Web: Dynamic layouts.
7. Print Materials
Rotate for print layouts:
# Rotate for spread
mediaproc image rotate page.jpg -a 90 -q 95
# Adjust for binding
mediaproc image rotate cover.jpg -a 3 --background white
Print: Layout preparation.
8. Product Photography
Create view variations:
# Different angles
mediaproc image rotate product.jpg -a 90 -o side-view.jpg
mediaproc image rotate product.jpg -a 180 -o back-view.jpg
E-commerce: Multiple views.
Combining with Other Commands
Auto-Orient + Rotate
Fix EXIF orientation then rotate:
# Fix EXIF orientation
mediaproc image auto-orient photo.jpg -o oriented.jpg
# Additional rotation if needed
mediaproc image rotate oriented.jpg -a 90
Photography: Complete orientation fix.
Rotate + Crop
Rotate then crop to remove empty corners:
# Rotate
mediaproc image rotate photo.jpg -a 45 --background white -o rotated.jpg
# Crop to content
mediaproc image crop rotated.jpg --x 100 --y 100 --width 800 --height 600
Composition: Clean rotated images.
Rotate + Border
Rotate then add frame:
# Rotate
mediaproc image rotate photo.jpg -a 5 --background white -o rotated.jpg
# Add border
mediaproc image border rotated.jpg --width 10 --color black
Framing: Artistic presentation.
Rotate + Resize
Rotate then resize to standard size:
# Rotate
mediaproc image rotate photo.jpg -a 90 -o rotated.jpg
# Resize
mediaproc image resize rotated.jpg -w 1920 -h 1080
Workflow: Complete transformation.
Technical Details
Rotation Algorithm
Uses high-quality interpolation:
- Bicubic: For smooth results
- Anti-aliasing: Reduces jagged edges
- Sub-pixel: Accurate positioning
Background Fill
For non-90° rotations:
- Fills empty corners with specified color
- Maintains image quality
- Transparent support for PNG/WebP
Performance
- 90°, 180°, 270°: Very fast (no interpolation)
- Other angles: Slower (requires interpolation)
- Small images (less than 1MP): ~50-100ms
- Medium images (5MP): ~150-250ms
- Large images (greater than 10MP): ~300-500ms
Image Dimensions
After rotation:
- 90°, 270°: Dimensions swap (WxH → HxW)
- Other angles: Dimensions increase to fit rotated content
Example:
- Original: 1000x800
- After 90°: 800x1000
- After 45°: ~1280x1280 (includes corners)
Best Practices
1. Use Standard Angles When Possible
90° increments are faster:
# Fast
mediaproc image rotate photo.jpg -a 90
# Slower
mediaproc image rotate photo.jpg -a 89
2. Match Background to Use Case
Transparent: Logos, overlays
mediaproc image rotate logo.png -a 45 --background transparent
White/Color: Photos, documents
mediaproc image rotate photo.jpg -a 30 --background white
3. Small Adjustments for Scanning
Use small angles for scanned documents:
# Subtle correction
mediaproc image rotate scan.jpg -a 1.5 --background white
4. Preview First
Use dry run for large batches:
mediaproc image rotate "photos/*.jpg" -a 90 --dry-run
5. Quality Settings
Standard: Default quality 90 High: Use -q 95 or 100 Web: Can use -q 80-85
# High quality
mediaproc image rotate photo.jpg -a 45 -q 95
6. Consider Output Format
PNG for transparency:
mediaproc image rotate logo.jpg -a 45 --background transparent -o logo.png
JPEG for photos:
mediaproc image rotate photo.png -a 90 -o photo.jpg
7. Batch Similar Angles
Group rotations by angle:
# All 90° rotations
mediaproc image rotate "portrait/*.jpg" -a 90
# All 180° rotations
mediaproc image rotate "upside-down/*.jpg" -a 180
Troubleshooting
Issue: Image Quality Loss
Problem: Rotated image looks blurry
Cause: Low quality setting or multiple rotations
Solution: Increase quality
# Low quality
mediaproc image rotate photo.jpg -a 45 -q 70
# Better quality
mediaproc image rotate photo.jpg -a 45 -q 95
Issue: Unwanted White Corners
Problem: White corners appear after rotation
Cause: Background not set to transparent
Solution: Use transparent background
# White corners (JPEG)
mediaproc image rotate image.jpg -a 45
# Transparent (PNG)
mediaproc image rotate image.jpg -a 45 --background transparent -o image.png
Issue: File Size Increased
Problem: Output larger than input
Cause: Dimensions increased (non-90° rotation) or format change
Solution: This is expected for diagonal rotations
# Original: 1000x800 (800KB)
# After 45°: ~1280x1280 (larger file)
Issue: Wrong Rotation Direction
Problem: Image rotated wrong way
Cause: Positive vs negative angle confusion
Solution: Use opposite sign
# Wrong direction
mediaproc image rotate photo.jpg -a 90
# Correct direction
mediaproc image rotate photo.jpg -a -90
Issue: Background Color Not Showing
Problem: Background stays transparent despite setting color
Cause: Output format doesn't support specified background
Solution: Ensure correct output format
# Won't work (JPEG doesn't support transparency)
mediaproc image rotate image.png -a 45 --background transparent -o output.jpg
# Works
mediaproc image rotate image.png -a 45 --background white -o output.jpg
Related Commands
- auto-orient - Fix EXIF orientation automatically
- flip - Flip horizontally
- flop - Flip vertically
- crop - Crop after rotation