• Facebook

    500 K / likes

  • Twitter

    1 M / followers

This is What Actually Happens Every Time Your Computer Rotates a Photo


Rotating an image in Photoshop might seem like a pretty simple process: you just… rotate it, right? Not quite. As this video from 2010 demonstrates, one of the ways a computer rotates an image is actually by applying 4 sequential transformations. (Warning: math incoming).

For image editing nerds, this demo is pretty fascinating. It was initially created by YouTube user IronMortality because of a limitation in MS Paint: you could only rotate by 90° at a time. To solve for this, he instead broke down the rotation process into its individual parts, and applied each of them one at a time.

In this case that involved: a horizontal skew, a vertical resize, a vertical skew, and a horizontal and vertical resize. Put mathematically, you have to horizontal skew by the desired angle of rotation (we’ll call it “x”), then vertical resize by 1/cos2(x), then vertical skew by -x, then horizontal and vertical stretch by cos(x).

What spits out the other end is this perfectly rotated image that you never actually… rotated. You just smushed, squeezed, and stretched it four ways:

This is, in fact, one of the algorithms computers use behind the scenes to rotate an image. So the next time you do something super simple, like rotating an image on your cell phone, Preview, Paint, or Photoshop, keep in mind: it’s probably a lot more complicated than it looks.

(via Reddit)