Automatically Fix Perspective and Straighten Photos in Photoshop
Perspective issues can make horizons crooked and buildings lean. Photoshop’s Camera Raw Filter includes Upright tools that analyze your image and automatically correct level, verticals, or both. You can further refine the result with sliders or by drawing guides for exact alignment.

Step-by-step instructions
Work non-destructively with a Smart Object
Right-click your image layer and choose Convert to Smart Object.
Go to Filter → Camera Raw Filter.
Try automatic Upright corrections
Press Shift+T or click the Transform icon in Camera Raw.
Test Upright modes: Auto, Level, Vertical, and Full.
Choose the mode that best balances your horizon and verticals (Auto is often best).
Refine with sliders
Adjust the available Transform sliders (e.g., Vertical, Horizontal, Rotate, Aspect, Scale) to fine-tune alignment.
Use the preview toggle to compare before/after.
Use Guided Upright for manual precision
Click the Guided Upright button.
Draw at least two guides along true verticals or horizontals in the image.
Delete a guide by selecting it and pressing Backspace/Delete.
Adjust sliders if needed after guiding.
Reset or apply
Hold Alt/Option to turn Cancel into Reset and click it to start over if needed.
Click OK to apply the correction and return to Photoshop.