Straighten a Photo in Photoshop with the Ruler Tool
When horizons or architectural lines are tilted, the Ruler Tool can correct them in a click. You’ll convert your image for non-destructive edits, draw a reference line, and use Straighten. Finally, you’ll scale to fill and center the composition with guides.

Step-by-step instructions
Prepare the layer for editing
File → Open and select your image.
In the Layers panel, convert Background to a normal layer (Layer from Background) to unlock it.
Go to Layer → Smart Objects → Convert to Smart Object.
Draw a level reference with the Ruler Tool
Click and hold the Eyedropper Tool in the toolbar and select Ruler Tool.
Drag along a line that should be horizontal (e.g., horizon, bridge).
Click the Straighten button in the options bar.
Fill transparent edges
Press Ctrl+T / Cmd+T to Free Transform.
Hold Shift to maintain proportions and scale up until transparency is outside the canvas, then press Enter/Return.
Center the image with guides
Go to View → Rulers, then drag vertical and horizontal guides to the canvas center.
Press Ctrl+T / Cmd+T and reposition so the subject aligns with the guides; press Enter/Return.