Ryan (tekman) wrote,
Ryan
tekman

EXIF orientation - math or lookup?

EXIF orientation numbers are kind of random. Starting at "normal", here's the number of 90 degree clockwise rotations needed to fix an image:

1 (0) -> 6 (1) -> 3 (2) -> 8 (3) -> 1 (0 mod 4)

So I've got these stuffed into a list (1, 6, 3, 8) and traverse it mod the length to figure out what to do when someone wants to rotate a photo clockwise or counter-clockwise.

Is there some mathy way to avoid the list in this case? For a moment I thought it was just (5*i % 8) + 1 given index i. Although that works for 0 -> 5 -> 2 -> 7, unfortunately 7 + 5 mod 8 ain't 0.
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 3 comments