Dosya Kalemi

Straightening a crooked scan

Updated 21 August 2026

Pages coming off a scanner are often a few degrees crooked: a stack fed in slightly askew, a sheet that slides as the lid comes down, a document photographed at an angle with a phone. A degree or two looks unimportant at a glance, but it adds to the work of reading and it noticeably lowers the accuracy of text recognition. This piece explains how the angle is found, which pages it cannot be found on, and what straightening does to the document.

How the angle is found

The method is called a projection profile. Dark pixels on the page are rotated by a candidate angle, spread into horizontal bands, and the counts in those bands are checked for how peaked they are. At the angle where the lines of text sit level, the pixels gather into a few bands and the profile sharpens; while the lines are tilted, those same pixels spread across the bands and the profile flattens. The right angle, in other words, is the one that makes the profile most peaked.

The search runs in two passes: first a coarse sweep in half-degree steps, then a fine sweep in steps of 0.05 degrees around the winner. The range searched is ±6 degrees, because skew off a scanner rarely exceeds three in practice. For the measurement each page is drawn at 120 dpi and reduced to a width of 1000 pixels; going higher adds nothing to accuracy and only adds time.

Measuring and correcting are separate steps, and that has a consequence you can use: you see which page will turn by how much before anything happens. Angles below a tenth of a degree leave the page untouched: a shift on that scale does not catch the eye, and turning the page for it would be work for nothing.

Some pages cannot be measured, and that is not a fault

The estimate works by looking at lines of text. Where there are no lines there is nothing to look at. So when the proportion of dark pixels on a page falls outside a certain range, the tool refuses to produce an angle: too low and the page is blank or nearly so, too high and the page is a dark image end to end — a full-page photograph, a scan that came out far too dark, a cover on a black background.

There is a confidence measure as well. If the score of the best angle does not stand far enough above the page's average, the result is treated as unreliable. On a page with text that ratio rises comfortably; on an image without pattern it stays close to one, which means the winning angle is a coincidence. Applying a random angle to such a page would not be straightening the skew but creating it.

Pages that could not be measured are counted separately in the results, and deliberately so: not measured does not mean straight. If you have an exhibit made of full-page photographs and it looks crooked to the eye, those pages need turning by hand with the Rotate tool.

Straightening does not turn the page into an image

The most important thing about this tool is not what it does but what it does not do. The page is not redrawn. The original page is embedded whole inside the new page, and what gets rotated is the drawing matrix. Everything inside it — the scan image, the text layer if there is one, vector drawings — stays exactly as it was.

The cost of the alternative is concrete. Turning every page into a fresh JPEG grows the file, drops the scan another notch in quality and, worst of all, throws away the invisible text layer of a document that has been through text recognition. Losing the searchability of a file you waited days of OCR for, in exchange for a two-degree correction, would be a poor trade.

For the same reason the file size barely moves. What is added to the document is a handful of drawing instructions; the image data is copied rather than re-encoded.

The cost: a straightened page loses what was attached to it

The embedding approach has a price, and we are not hiding it. The page's content goes into an embeddable object, but the extra objects attached to the page — links, form fields, comment and note bubbles — sit outside that object and so are not carried over on a straightened page.

The loss is limited to the pages that were touched. Pages that are not straightened are not embedded; they are copied as they are, and a copied page keeps all of its attachments. In a hundred-page document with three crooked pages, only those three pay the price.

In practice it often does not come up at all, because a crooked page means a scanned page, and a scanned page rarely carries links or form fields to begin with. But if you are working on a filled-in form or a document with comments on it, setting a copy aside before straightening is worth the moment it takes.

Skew and sideways are not the same thing

This tool is for shifts of a few degrees. A page lying 90 degrees on its side, or upside down, is not skewed but scanned in the wrong orientation, and the answer there is not measurement but turning it outright. The Rotate PDF tool applies 90 degrees right, 180 degrees, or 90 degrees left to the whole document or to the pages you pick.

The distinction is in the code too: the estimate searches a range of ±6 degrees, and the correction applied never exceeds 10. That is not a shortcoming but a safety catch — a larger angle is taken as a sign that the measurement went wrong, and doing nothing beats turning a page on a bad measurement.

If both jobs are needed, order matters: straighten the orientation first with Rotate, then take out the remaining skew with Straighten Scan. The other way round, a page on its side has its text lines running vertically, so the measurement cannot produce anything meaningful.

Common questions

Are my pages turned into images when they are straightened?
No. The original page is embedded whole and only the drawing matrix is rotated; the scan image, the text layer if there is one, and vector drawings all stay as they were. If the document was searchable, it stays searchable afterwards.
No angle came out for some pages — what does that mean?
The measurement rests on lines of text; if a page is blank, is a dark image end to end, or does not clear the confidence threshold, no angle is produced. That means "no reliable measurement could be made here", not "this page is straight". If it looks crooked to the eye, turn it by hand with the Rotate tool.
Are links and form fields kept on a straightened page?
Not on a straightened page: objects attached to the page — links, form fields, comments — are left outside during embedding. Pages that were not touched are copied as they are and lose nothing. Since scanned pages rarely carry such attachments, most documents never notice.
My page is lying 90 degrees on its side. Will this tool fix it?
No, that is orientation rather than skew. Use the Rotate PDF tool. The estimate searches a range of ±6 degrees and the correction applied never exceeds 10; a larger angle means the measurement went wrong.
Does straightening make the file bigger?
Not noticeably. Pages are not redrawn, so the image data is never re-encoded — only a handful of drawing instructions are added.
Is my file uploaded anywhere?
No. The measurement is made by drawing the pages in your own tab, and the rotation is applied in the same tab; the document does not leave your machine.

Tools for this job

All guides