Rotate or Flip an Image with PowerShell (System.Drawing)

Use the built-in .NET System.Drawing RotateFlip method to rotate or mirror a picture from the command line.

Windowssystem-drawingimagepowershellLow risk
Load the image with [System.Drawing.Image]::FromFile, call RotateFlip with a RotateFlipType value, then Save to a new file.

01Command

Command
$ Add-Type -AssemblyName System.Drawing; $img=[System.Drawing.Image]::FromFile('C:\Users\me\photo.jpg'); $img.RotateFlip([System.Drawing.RotateFlipType]::Rotate90FlipNone); $img.Save('C:\Users\me\photo-rot.jpg'); $img.Dispose()

02What it does

System.Drawing ships with Windows and needs no installs. RotateFlipType combines rotation (90/180/270) and mirroring (FlipX/FlipXY) in a single enum, so a vertical phone photo becomes horizontal in one call. Always Dispose the image afterwards or the file stays locked; save to a new filename because JPEG re-encoding is lossy.

03Risk

RiskLow risk
RequirementsWindows PowerShell 5.1 (System.Drawing is not loaded in .NET Core editions; on pwsh use an alternative or run under Windows PowerShell)
!Warning: Saving over the original file re-encodes the JPEG and loses quality; write to a new file first.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Image Class (System.Drawing)
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Documents Image.FromFile, Image.RotateFlip and Image.Save — the three members the one-liner chains together.
  • RotateFlipType Enum (System.Drawing)
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Lists every RotateFlipType member (Rotate90FlipNone, Rotate180FlipXY, etc.) used by Image.RotateFlip to rotate and mirror an image in place.

Last verified: 2026-09-17 · Category: Media

06Related solutions