FA-78841 / Image orientation metadata / Open access
Pixel bake turns tag-6 photos counter-clockwise · case 01
Portrait phone photos tagged 6 are baked upside down relative to what every viewer shows.
ROOT CAUSE
The tag-6 branch samples grid[c][w-1-r], the counter-clockwise source, instead of grid[h-1-c][r].
VERIFIED REPAIR
Sample grid[h-1-c][r] so the stored left column, read bottom to top, becomes the top row.
Unsuccessful approach: Mirroring from the width (w-1-c) instead of the height is only right for square images and wraps negative indexes on tall ones.
Case contract
Bake an EXIF-style orientation tag (1..8) into a row-major pixel grid so the result displays upright. Tags 2/4 mirror horizontally/vertically, 3 rotates 180, 6 rotates 90 clockwise, 8 rotates 90 counter-clockwise, 5 transposes and 7 transverses; tags outside 1..8 are treated as 1. Tags 5..8 swap the output width and height.
Why this case matters
Camera, phone and scanner images carry an orientation hint separately from the stored pixels; galleries, thumbnailers, editors and upload pipelines must interpret it consistently or photos appear sideways, mirrored or doubly rotated.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(grid, tag):
h = len(grid)
w = len(grid[0]) if h else 0
if tag not in range(1, 9):
tag = 1
if tag in (5, 6, 7, 8):
out_h, out_w = w, h
else:
out_h, out_w = h, w
out = []
for r in range(out_h):
row = []
for c in range(out_w):
if tag == 1:
v = grid[r][c]
elif tag == 2:
v = grid[r][w - 1 - c]
elif tag == 3:
v = grid[h - 1 - r][w - 1 - c]
elif tag == 4:
v = grid[h - 1 - r][c]
elif tag == 5:
v = grid[c][r]
elif tag == 6:
v = grid[c][w - 1 - r]
elif tag == 7:
v = grid[h - 1 - c][w - 1 - r]
else:
v = grid[c][w - 1 - r]
row.append(v)
out.append(row)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[([[1, 2, 3, 4], [11, 12, 13, 14], [21, 22, 23, 24], [31, 32, 33, 34]], 6), [[31, 21, 11, 1], [32, 22, 12, 2], [33, 23, 13, 3], [34, 24, 14, 4]]], [([[1], [11], [21]], 6), [[21, 11, 1]]], [([[1], [11], [21], [31]], 8), [[1, 11, 21, 31]]], [([[1, 2, 3, 4]], 5), [[1], [2], [3], [4]]], [([[1, 2, 3, 4]], 2), [[4, 3, 2, 1]]], [([[1, 2], [11, 12], [21, 22], [31, 32]], 2), [[2, 1], [12, 11], [22, 21], [32, 31]]], [([[1, 2, 3]], 4), [[1, 2, 3]]], [([[1, 2, 3], [11, 12, 13], [21, 22, 23]], 6), [[21, 11, 1], [22, 12, 2], [23, 13, 3]]]], [[([[2, 3], [12, 13], [22, 23], [32, 33]], 6), [[32, 22, 12, 2], [33, 23, 13, 3]]], [([[2], [12]], 6), [[12, 2]]], [([[2, 3, 4, 5], [12, 13, 14, 15]], 9), [[2, 3, 4, 5], [12, 13, 14, 15]]], [([[2, 3, 4], [12, 13, 14], [22, 23, 24]], 0), [[2, 3, 4], [12, 13, 14], [22, 23, 24]]], [([[2]], 1), [[2]]], [([[2, 3, 4], [12, 13, 14]], 5), [[2, 12], [3, 13], [4, 14]]], [([[2, 3, 4]], 3), [[4, 3, 2]]], [([[2], [12], [22]], 6), [[22, 12, 2]]]], [[([[3], [13]], 6), [[13, 3]]], [([[3, 4], [13, 14], [23, 24]], 6), [[23, 13, 3], [24, 14, 4]]], [([[3, 4], [13, 14], [23, 24], [33, 34]], 8), [[4, 14, 24, 34], [3, 13, 23, 33]]], [([[3]], 8), [[3]]], [([[3, 4, 5, 6], [13, 14, 15, 16], [23, 24, 25, 26]], 8), [[6, 16, 26], [5, 15, 25], [4, 14, 24], [3, 13, 23]]], [([[3], [13]], 3), [[13], [3]]], [([[3, 4, 5, 6], [13, 14, 15, 16]], 0), [[3, 4, 5, 6], [13, 14, 15, 16]]], [([[3, 4, 5, 6], [13, 14, 15, 16], [23, 24, 25, 26], [33, 34, 35, 36]], 6), [[33, 23, 13, 3], [34, 24, 14, 4], [35, 25, 15, 5], [36, 26, 16, 6]]]], [[([[4], [14]], 6), [[14, 4]]], [([[4], [14], [24]], 6), [[24, 14, 4]]], [([[4, 5, 6, 7], [14, 15, 16, 17], [24, 25, 26, 27]], 9), [[4, 5, 6, 7], [14, 15, 16, 17], [24, 25, 26, 27]]], [([[4, 5, 6], [14, 15, 16]], 3), [[16, 15, 14], [6, 5, 4]]], [([[4, 5], [14, 15]], 5), [[4, 14], [5, 15]]], [([[4, 5, 6, 7], [14, 15, 16, 17], [24, 25, 26, 27], [34, 35, 36, 37]], 9), [[4, 5, 6, 7], [14, 15, 16, 17], [24, 25, 26, 27], [34, 35, 36, 37]]], [([[4]], 5), [[4]]], [([[4, 5, 6, 7], [14, 15, 16, 17], [24, 25, 26, 27], [34, 35, 36, 37]], 6), [[34, 24, 14, 4], [35, 25, 15, 5], [36, 26, 16, 6], [37, 27, 17, 7]]]], [[([[5], [15], [25], [35]], 6), [[35, 25, 15, 5]]], [([[5, 6], [15, 16], [25, 26], [35, 36]], 6), [[35, 25, 15, 5], [36, 26, 16, 6]]], [([[5], [15], [25]], 2), [[5], [15], [25]]], [([[5], [15]], 4), [[15], [5]]], [([[5, 6]], 9), [[5, 6]]], [([[5]], 6), [[5]]], [([[5], [15], [25], [35]], 2), [[5], [15], [25], [35]]], [([[5], [15], [25]], 6), [[25, 15, 5]]]]]
labels = ["regression: tag 6 clockwise source index", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (labels[i % len(labels)], i), solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: tag 6 clockwise source index 0 | [[4, 14, 24, 34], [3, 13, 23, 33], [2, 12, 22, 32], [1, 11, 21, 31]] | [[31, 21, 11, 1], [32, 22, 12, 2], [33, 23, 13, 3], [34, 24, 14, 4]] | Failed |
| repair trap 1 | [[1, 11, 21]] | [[21, 11, 1]] | Failed |
| combined fault 2 | [[1, 11, 21, 31]] | [[1, 11, 21, 31]] | Passed |
| control 3 | [[1], [2], [3], [4]] | [[1], [2], [3], [4]] | Passed |
| control 4 | [[4, 3, 2, 1]] | [[4, 3, 2, 1]] | Passed |
| boundary 5 | [[2, 1], [12, 11], [22, 21], [32, 31]] | [[2, 1], [12, 11], [22, 21], [32, 31]] | Passed |
| boundary 6 | [[1, 2, 3]] | [[1, 2, 3]] | Passed |
| control 7 | [[3, 13, 23], [2, 12, 22], [1, 11, 21]] | [[21, 11, 1], [22, 12, 2], [23, 13, 3]] | Failed |
SHA-256 / ab912af2ecd836662d053fd6d0d53c8078e68e8fb81697c49bed6f9654055f57
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(grid, tag):
h = len(grid)
w = len(grid[0]) if h else 0
if tag not in range(1, 9):
tag = 1
if tag in (5, 6, 7, 8):
out_h, out_w = w, h
else:
out_h, out_w = h, w
out = []
for r in range(out_h):
row = []
for c in range(out_w):
if tag == 1:
v = grid[r][c]
elif tag == 2:
v = grid[r][w - 1 - c]
elif tag == 3:
v = grid[h - 1 - r][w - 1 - c]
elif tag == 4:
v = grid[h - 1 - r][c]
elif tag == 5:
v = grid[c][r]
elif tag == 6:
v = grid[w - 1 - c][r]
elif tag == 7:
v = grid[h - 1 - c][w - 1 - r]
else:
v = grid[c][w - 1 - r]
row.append(v)
out.append(row)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[([[1, 2, 3, 4], [11, 12, 13, 14], [21, 22, 23, 24], [31, 32, 33, 34]], 6), [[31, 21, 11, 1], [32, 22, 12, 2], [33, 23, 13, 3], [34, 24, 14, 4]]], [([[1], [11], [21]], 6), [[21, 11, 1]]], [([[1], [11], [21], [31]], 8), [[1, 11, 21, 31]]], [([[1, 2, 3, 4]], 5), [[1], [2], [3], [4]]], [([[1, 2, 3, 4]], 2), [[4, 3, 2, 1]]], [([[1, 2], [11, 12], [21, 22], [31, 32]], 2), [[2, 1], [12, 11], [22, 21], [32, 31]]], [([[1, 2, 3]], 4), [[1, 2, 3]]], [([[1, 2, 3], [11, 12, 13], [21, 22, 23]], 6), [[21, 11, 1], [22, 12, 2], [23, 13, 3]]]], [[([[2, 3], [12, 13], [22, 23], [32, 33]], 6), [[32, 22, 12, 2], [33, 23, 13, 3]]], [([[2], [12]], 6), [[12, 2]]], [([[2, 3, 4, 5], [12, 13, 14, 15]], 9), [[2, 3, 4, 5], [12, 13, 14, 15]]], [([[2, 3, 4], [12, 13, 14], [22, 23, 24]], 0), [[2, 3, 4], [12, 13, 14], [22, 23, 24]]], [([[2]], 1), [[2]]], [([[2, 3, 4], [12, 13, 14]], 5), [[2, 12], [3, 13], [4, 14]]], [([[2, 3, 4]], 3), [[4, 3, 2]]], [([[2], [12], [22]], 6), [[22, 12, 2]]]], [[([[3], [13]], 6), [[13, 3]]], [([[3, 4], [13, 14], [23, 24]], 6), [[23, 13, 3], [24, 14, 4]]], [([[3, 4], [13, 14], [23, 24], [33, 34]], 8), [[4, 14, 24, 34], [3, 13, 23, 33]]], [([[3]], 8), [[3]]], [([[3, 4, 5, 6], [13, 14, 15, 16], [23, 24, 25, 26]], 8), [[6, 16, 26], [5, 15, 25], [4, 14, 24], [3, 13, 23]]], [([[3], [13]], 3), [[13], [3]]], [([[3, 4, 5, 6], [13, 14, 15, 16]], 0), [[3, 4, 5, 6], [13, 14, 15, 16]]], [([[3, 4, 5, 6], [13, 14, 15, 16], [23, 24, 25, 26], [33, 34, 35, 36]], 6), [[33, 23, 13, 3], [34, 24, 14, 4], [35, 25, 15, 5], [36, 26, 16, 6]]]], [[([[4], [14]], 6), [[14, 4]]], [([[4], [14], [24]], 6), [[24, 14, 4]]], [([[4, 5, 6, 7], [14, 15, 16, 17], [24, 25, 26, 27]], 9), [[4, 5, 6, 7], [14, 15, 16, 17], [24, 25, 26, 27]]], [([[4, 5, 6], [14, 15, 16]], 3), [[16, 15, 14], [6, 5, 4]]], [([[4, 5], [14, 15]], 5), [[4, 14], [5, 15]]], [([[4, 5, 6, 7], [14, 15, 16, 17], [24, 25, 26, 27], [34, 35, 36, 37]], 9), [[4, 5, 6, 7], [14, 15, 16, 17], [24, 25, 26, 27], [34, 35, 36, 37]]], [([[4]], 5), [[4]]], [([[4, 5, 6, 7], [14, 15, 16, 17], [24, 25, 26, 27], [34, 35, 36, 37]], 6), [[34, 24, 14, 4], [35, 25, 15, 5], [36, 26, 16, 6], [37, 27, 17, 7]]]], [[([[5], [15], [25], [35]], 6), [[35, 25, 15, 5]]], [([[5, 6], [15, 16], [25, 26], [35, 36]], 6), [[35, 25, 15, 5], [36, 26, 16, 6]]], [([[5], [15], [25]], 2), [[5], [15], [25]]], [([[5], [15]], 4), [[15], [5]]], [([[5, 6]], 9), [[5, 6]]], [([[5]], 6), [[5]]], [([[5], [15], [25], [35]], 2), [[5], [15], [25], [35]]], [([[5], [15], [25]], 6), [[25, 15, 5]]]]]
labels = ["regression: tag 6 clockwise source index", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (labels[i % len(labels)], i), solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: tag 6 clockwise source index 0 | [[31, 21, 11, 1], [32, 22, 12, 2], [33, 23, 13, 3], [34, 24, 14, 4]] | [[31, 21, 11, 1], [32, 22, 12, 2], [33, 23, 13, 3], [34, 24, 14, 4]] | Passed |
| repair trap 1 | [[1, 21, 11]] | [[21, 11, 1]] | Failed |
| combined fault 2 | [[1, 11, 21, 31]] | [[1, 11, 21, 31]] | Passed |
| control 3 | [[1], [2], [3], [4]] | [[1], [2], [3], [4]] | Passed |
| control 4 | [[4, 3, 2, 1]] | [[4, 3, 2, 1]] | Passed |
| boundary 5 | [[2, 1], [12, 11], [22, 21], [32, 31]] | [[2, 1], [12, 11], [22, 21], [32, 31]] | Passed |
| boundary 6 | [[1, 2, 3]] | [[1, 2, 3]] | Passed |
| control 7 | [[21, 11, 1], [22, 12, 2], [23, 13, 3]] | [[21, 11, 1], [22, 12, 2], [23, 13, 3]] | Passed |
SHA-256 / aa00c2f6897a4ac0990bbef372ebdeef1875e46df17909da1cc2157049df55a3
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(grid, tag):
h = len(grid)
w = len(grid[0]) if h else 0
if tag not in range(1, 9):
tag = 1
if tag in (5, 6, 7, 8):
out_h, out_w = w, h
else:
out_h, out_w = h, w
out = []
for r in range(out_h):
row = []
for c in range(out_w):
if tag == 1:
v = grid[r][c]
elif tag == 2:
v = grid[r][w - 1 - c]
elif tag == 3:
v = grid[h - 1 - r][w - 1 - c]
elif tag == 4:
v = grid[h - 1 - r][c]
elif tag == 5:
v = grid[c][r]
elif tag == 6:
v = grid[h - 1 - c][r]
elif tag == 7:
v = grid[h - 1 - c][w - 1 - r]
else:
v = grid[c][w - 1 - r]
row.append(v)
out.append(row)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[([[1, 2, 3, 4], [11, 12, 13, 14], [21, 22, 23, 24], [31, 32, 33, 34]], 6), [[31, 21, 11, 1], [32, 22, 12, 2], [33, 23, 13, 3], [34, 24, 14, 4]]], [([[1], [11], [21]], 6), [[21, 11, 1]]], [([[1], [11], [21], [31]], 8), [[1, 11, 21, 31]]], [([[1, 2, 3, 4]], 5), [[1], [2], [3], [4]]], [([[1, 2, 3, 4]], 2), [[4, 3, 2, 1]]], [([[1, 2], [11, 12], [21, 22], [31, 32]], 2), [[2, 1], [12, 11], [22, 21], [32, 31]]], [([[1, 2, 3]], 4), [[1, 2, 3]]], [([[1, 2, 3], [11, 12, 13], [21, 22, 23]], 6), [[21, 11, 1], [22, 12, 2], [23, 13, 3]]]], [[([[2, 3], [12, 13], [22, 23], [32, 33]], 6), [[32, 22, 12, 2], [33, 23, 13, 3]]], [([[2], [12]], 6), [[12, 2]]], [([[2, 3, 4, 5], [12, 13, 14, 15]], 9), [[2, 3, 4, 5], [12, 13, 14, 15]]], [([[2, 3, 4], [12, 13, 14], [22, 23, 24]], 0), [[2, 3, 4], [12, 13, 14], [22, 23, 24]]], [([[2]], 1), [[2]]], [([[2, 3, 4], [12, 13, 14]], 5), [[2, 12], [3, 13], [4, 14]]], [([[2, 3, 4]], 3), [[4, 3, 2]]], [([[2], [12], [22]], 6), [[22, 12, 2]]]], [[([[3], [13]], 6), [[13, 3]]], [([[3, 4], [13, 14], [23, 24]], 6), [[23, 13, 3], [24, 14, 4]]], [([[3, 4], [13, 14], [23, 24], [33, 34]], 8), [[4, 14, 24, 34], [3, 13, 23, 33]]], [([[3]], 8), [[3]]], [([[3, 4, 5, 6], [13, 14, 15, 16], [23, 24, 25, 26]], 8), [[6, 16, 26], [5, 15, 25], [4, 14, 24], [3, 13, 23]]], [([[3], [13]], 3), [[13], [3]]], [([[3, 4, 5, 6], [13, 14, 15, 16]], 0), [[3, 4, 5, 6], [13, 14, 15, 16]]], [([[3, 4, 5, 6], [13, 14, 15, 16], [23, 24, 25, 26], [33, 34, 35, 36]], 6), [[33, 23, 13, 3], [34, 24, 14, 4], [35, 25, 15, 5], [36, 26, 16, 6]]]], [[([[4], [14]], 6), [[14, 4]]], [([[4], [14], [24]], 6), [[24, 14, 4]]], [([[4, 5, 6, 7], [14, 15, 16, 17], [24, 25, 26, 27]], 9), [[4, 5, 6, 7], [14, 15, 16, 17], [24, 25, 26, 27]]], [([[4, 5, 6], [14, 15, 16]], 3), [[16, 15, 14], [6, 5, 4]]], [([[4, 5], [14, 15]], 5), [[4, 14], [5, 15]]], [([[4, 5, 6, 7], [14, 15, 16, 17], [24, 25, 26, 27], [34, 35, 36, 37]], 9), [[4, 5, 6, 7], [14, 15, 16, 17], [24, 25, 26, 27], [34, 35, 36, 37]]], [([[4]], 5), [[4]]], [([[4, 5, 6, 7], [14, 15, 16, 17], [24, 25, 26, 27], [34, 35, 36, 37]], 6), [[34, 24, 14, 4], [35, 25, 15, 5], [36, 26, 16, 6], [37, 27, 17, 7]]]], [[([[5], [15], [25], [35]], 6), [[35, 25, 15, 5]]], [([[5, 6], [15, 16], [25, 26], [35, 36]], 6), [[35, 25, 15, 5], [36, 26, 16, 6]]], [([[5], [15], [25]], 2), [[5], [15], [25]]], [([[5], [15]], 4), [[15], [5]]], [([[5, 6]], 9), [[5, 6]]], [([[5]], 6), [[5]]], [([[5], [15], [25], [35]], 2), [[5], [15], [25], [35]]], [([[5], [15], [25]], 6), [[25, 15, 5]]]]]
labels = ["regression: tag 6 clockwise source index", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (labels[i % len(labels)], i), solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: tag 6 clockwise source index 0 | [[31, 21, 11, 1], [32, 22, 12, 2], [33, 23, 13, 3], [34, 24, 14, 4]] | [[31, 21, 11, 1], [32, 22, 12, 2], [33, 23, 13, 3], [34, 24, 14, 4]] | Passed |
| repair trap 1 | [[21, 11, 1]] | [[21, 11, 1]] | Passed |
| combined fault 2 | [[1, 11, 21, 31]] | [[1, 11, 21, 31]] | Passed |
| control 3 | [[1], [2], [3], [4]] | [[1], [2], [3], [4]] | Passed |
| control 4 | [[4, 3, 2, 1]] | [[4, 3, 2, 1]] | Passed |
| boundary 5 | [[2, 1], [12, 11], [22, 21], [32, 31]] | [[2, 1], [12, 11], [22, 21], [32, 31]] | Passed |
| boundary 6 | [[1, 2, 3]] | [[1, 2, 3]] | Passed |
| control 7 | [[21, 11, 1], [22, 12, 2], [23, 13, 3]] | [[21, 11, 1], [22, 12, 2], [23, 13, 3]] | Passed |
SHA-256 / 4e8a5e945d6311d7ced3fa2dba37fa1c9072a8bb69c72e17aae2a839ba45ecb6
Verification & scope
A deterministic bounded teaching model with a stipulated contract; it makes no claim of conformance to any published specification. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:49:39.207224+00:00.
Case digest / 2976057049abb8f85beff875400021c164bc4eeedce931e37873cf4936f1d50d