Watch the full tutorial
In this episode of the Darktable Basics series, we look at how to straighten a horizon, correct perspective and crop an image. Since Darktable 3.8, this work is split between two modules: rotate and perspective, and crop.
Before we start, one thing to keep in mind: like everything in Darktable, both modules are non-destructive. If you crop too much or tilt the horizon too far, you can always go back to the previous state. Nothing is lost.
Rotate and perspective
Straighten the horizon
The most basic job of this module is rotating the image. You can move the rotation slider and the image turns, with a frame showing the new edges. The pixels outside the frame are kept, so nothing is thrown away.
The slider works, but it’s not the most efficient way. If you come from Lightroom, you probably prefer drawing a line along the horizon, and Darktable lets you do exactly that: right-click on the image and drag a line along something that should be level. Darktable rotates the image to match. For a quick horizon fix, this is the method I recommend.
Manual perspective sliders
The real power of this module is perspective correction. Open the manual perspective section, which is collapsed by default, and you get sliders for lens shift (vertical and horizontal) and shear.
You can drag them, but getting precise results that way is hard. One tip that works on every slider in Darktable: right-click on a slider and type a value, for example 0.05, then press Enter. Handy when you know the exact number you want.
Drawing perspective lines
The easiest way to correct perspective is to show Darktable which lines should be straight. There are three ways to do it:
- Draw lines manually on the image.
- Use a rectangle that you place over the shape of your subject, moving its corners to follow the lines in the image.
- Let Darktable analyse the image and detect the lines for you.
I start with the manual method. Zoom in, then draw lines along edges that should be straight. Darktable shows vertical lines in green and horizontal lines in blue. You can draw as many as you like. Take your time: zoom in and place each line exactly along a beam or an edge. The more accurate and numerous your lines, the better the correction.
Once your lines are in place, use the buttons to fix the vertical perspective, the horizontal perspective, or both. Darktable adjusts the angles so that your vertical lines become truly vertical and your horizontal lines truly horizontal. If the result isn’t quite right, add more lines.
Automatic line detection
The third option is the automatic analysis. Click it and Darktable draws lines it finds in the image: green for vertical and blue for horizontal lines it will use, and red and yellow for lines it isn’t sure about and will ignore.
You can correct its choices. Zoom in and right-click a line to exclude it, which turns it red or yellow.
On clean architectural images, this works fast and well. On busy images, with lots of lines that aren’t truly vertical or horizontal, it struggles more. In my example, a beam on the right side that was leaning before is now perfectly vertical after the automatic correction.
Automatic cropping
Correcting perspective warps the image, so the edges no longer form a clean rectangle. The automatic cropping setting decides what happens:
- Original format keeps the aspect ratio of your original image.
- Largest area keeps as much of the image as possible, but the aspect ratio changes.
- Off keeps everything and fills the gaps around the image with black pixels.
I usually choose largest area and recrop afterwards if needed. Which brings us to the second module.
Crop
Even after the perspective correction, nothing is lost: go back to rotate and perspective and all your pixels are still there.
The crop module is fairly self-explanatory. You can pick an aspect ratio: original image, square, wide cinematic or panorama formats, and more. Or choose freehand and drag the crop however you like.
Guides
The most useful part of the crop module, for me, is the guides. You can show or hide them and choose their type:
- Rule of thirds, a good default for landscapes.
- Golden sections.
- Golden spiral, useful for portraits when you want to lead the eye to one point.
If the guides are hard to see on your image, for example grey lines over a bluish photo, change their colour (I use yellow) and raise the contrast so they stand out.
And again, cropping is non-destructive. You can make one crop for your portfolio, then come back later and switch to a square crop for Instagram, without losing anything.
Wrapping up
With these two modules, you can fix a crooked horizon, correct converging lines and crop your image, all without ever destroying a pixel. Rotate and perspective does the geometry, crop does the framing.
If you have questions, leave a comment on the video. And if there’s a topic you’d like to see in the Darktable Basics series, let me know.