Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

How do I automatically straighten the horizon in a photo?

Participant ,
Jan 11, 2023 Jan 11, 2023

Hello. Please help me solve the problem.

 

I have a lot of studio photos taken without a tripod, so the horizon is often tilted at different angles.
There is a clear contrast between the wall and the floor.

 

I need to automatically straighten the horizon in these photos, no change in perspective, no cropping. Just the angle of the slope.

Lightroom, camera raw are not up to the task.


The manual method, using a ruler, is not for me either.

Perhaps there is some Script that can help me solve my problem?

 

*Sample photo added.

IMG_20230112_005742_828.jpg

TOPICS
Actions and scripting
6.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Mentor , Jan 13, 2023 Jan 13, 2023
quote

I do not know how to work with java script, but I have some ideas.
If there are people here who understand this, tell me if it is realistic to implement, or am I mistaken)


By @Andrew Bold

 

Your ideas sound reasonable, but don't forget that we are limited by the runtime environment. Photoshop's scripting environment severely limits our ability to analyze images.

 

There are several ways to solve your problem, but all of them have some disadvantages and depend heavily on how the rest of the imag

...
Translate
Mentor , Aug 27, 2023 Aug 27, 2023

Hi! Unfortunately, such scripts are not universal and it works well only for solving a specific problem.

Try this one. It works well on the image posted to you, but there may be issues with other images.
I've modified the script so that it tries to find an area in the bottom half of the frame with a big difference in brightness, assuming that's where the floor boundary is. For large images, you can increase the size of the BATCH_SIZE constant (this is the number of consecutive pixels within which

...
Translate
Adobe
Contributor ,
Oct 12, 2025 Oct 12, 2025

Can you make the "after" picture you are looking for manually and post it here please?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 13, 2025 Oct 13, 2025
LATEST

Hello. The issue has been resolved.
At the beginning of the thread, there are examples, followed by a ready-to-use script.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines