FA-78881 / Image orientation metadata / Open access
Mirrored region boxes shift one pixel toward the origin · case 01
Crop rectangles on mirrored images are off by one column and can start at -1.
ROOT CAUSE
The pixel-index mirror w-1-x is applied to half-open edges, which already mirror as w-x.
VERIFIED REPAIR
Mirror interval edges as [w-x1, w-x0).
Unsuccessful approach: Mirroring each edge in place without exchanging them yields a negative width.
Case contract
Map a half-open face/crop region [x, y, width, height] given in stored pixel space of an image of size [w, h] into displayed space for orientation tag 1..8. The region is first clipped to the stored image; an empty clipped region returns None, and an unknown tag returns None. Mirroring a half-open interval [a, b) over extent e gives [e-b, e-a); tags 5..8 exchange axes after the flips.
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(size, tag, box):
w, h = size
x0, y0, bw, bh = box
x1 = min(x0 + bw, w)
y1 = min(y0 + bh, h)
x0 = max(x0, 0)
y0 = max(y0, 0)
if x1 <= x0 or y1 <= y0:
return None
table = {1: (0, 0, 0), 2: (1, 0, 0), 3: (1, 1, 0), 4: (0, 1, 0), 5: (0, 0, 1), 6: (0, 1, 1), 7: (1, 1, 1), 8: (1, 0, 1)}
if tag not in table:
return None
fx, fy, tr = table[tag]
if fx:
x0, x1 = w - 1 - x1, w - 1 - x0
if fy:
y0, y1 = h - y1, h - y0
if tr:
x0, y0, x1, y1 = y0, x0, y1, x1
return [x0, y0, x1 - x0, y1 - y0]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[([5, 6], 8, [-2, 0, 4, 1]), [0, 3, 1, 2]], [([2, 7], 7, [1, 6, 3, 3]), [0, 0, 1, 1]], [([5, 1], 6, [-3, -2, 5, 4]), [0, 0, 1, 2]], [([7, 5], 1, [6, -1, 4, 0]), None], [([3, 4], 3, [-2, 3, 0, 2]), None], [([2, 4], 8, [2, 1, 3, 3]), None], [([2, 4], 7, [1, -3, 3, 3]), None], [([4, 1], 7, [-2, -2, 3, 5]), [0, 3, 1, 1]]], [[([6, 4], 3, [-2, 2, 5, 5]), [3, 0, 3, 2]], [([1, 4], 3, [0, -3, 3, 5]), [0, 2, 1, 2]], [([3, 5], 0, [-3, -2, 2, 4]), None], [([3, 1], 1, [2, 2, 2, 0]), None], [([4, 1], 3, [6, 3, 2, 4]), None], [([5, 5], 6, [6, 3, 5, 0]), None], [([4, 5], 1, [1, 2, 5, 4]), [1, 2, 3, 3]], [([7, 7], 8, [2, 1, 5, 3]), [1, 0, 3, 5]]], [[([2, 2], 2, [1, 0, 5, 4]), [0, 0, 1, 2]], [([6, 4], 2, [2, -2, 1, 4]), [3, 0, 1, 2]], [([4, 5], 8, [2, -2, 0, 2]), None], [([6, 4], 6, [2, 1, 3, 4]), [0, 2, 3, 3]], [([1, 5], 9, [2, 3, 4, 4]), None], [([6, 1], 2, [2, 1, 3, 0]), None], [([1, 2], 9, [-2, 1, 1, 3]), None], [([5, 2], 8, [1, 1, 5, 1]), [1, 0, 1, 4]]], [[([4, 4], 7, [1, 2, 5, 5]), [0, 0, 2, 3]], [([6, 2], 2, [-1, 1, 5, 5]), [2, 1, 4, 1]], [([3, 7], 7, [-1, 6, 2, 0]), None], [([3, 6], 8, [6, -2, 2, 3]), None], [([7, 7], 2, [-2, 0, 0, 4]), None], [([2, 5], 1, [1, 6, 5, 2]), None], [([5, 5], 1, [6, 1, 5, 4]), None], [([7, 5], 8, [0, 4, 5, 5]), [4, 2, 1, 5]]], [[([7, 6], 8, [3, 2, 3, 2]), [2, 1, 2, 3]], [([2, 6], 7, [-3, 3, 4, 5]), [0, 1, 3, 1]], [([1, 1], 7, [1, -3, 2, 0]), None], [([4, 5], 6, [1, 3, 0, 5]), None], [([4, 1], 0, [2, 4, 5, 5]), None], [([6, 7], 7, [6, 0, 3, 1]), None], [([2, 4], 3, [5, 0, 1, 5]), None], [([7, 1], 7, [0, -2, 5, 4]), [0, 2, 1, 5]]]]
labels = ["regression: half-open horizontal mirror", "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: half-open horizontal mirror 0 | [0, 2, 1, 2] | [0, 3, 1, 2] | Failed |
| repair trap 1 | [0, -1, 1, 1] | [0, 0, 1, 1] | Failed |
| combined fault 2 | [0, 0, 1, 2] | [0, 0, 1, 2] | Passed |
| control 3 | None | None | Passed |
| control 4 | None | None | Passed |
| boundary 5 | None | None | Passed |
| boundary 6 | None | None | Passed |
| control 7 | [0, 2, 1, 1] | [0, 3, 1, 1] | Failed |
SHA-256 / 8d7db1f358202b4da5afcbc3a0a3dfe57b8c05696f1c8458b567bc0ca3978fde
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(size, tag, box):
w, h = size
x0, y0, bw, bh = box
x1 = min(x0 + bw, w)
y1 = min(y0 + bh, h)
x0 = max(x0, 0)
y0 = max(y0, 0)
if x1 <= x0 or y1 <= y0:
return None
table = {1: (0, 0, 0), 2: (1, 0, 0), 3: (1, 1, 0), 4: (0, 1, 0), 5: (0, 0, 1), 6: (0, 1, 1), 7: (1, 1, 1), 8: (1, 0, 1)}
if tag not in table:
return None
fx, fy, tr = table[tag]
if fx:
x0, x1 = w - x0, w - x1
if fy:
y0, y1 = h - y1, h - y0
if tr:
x0, y0, x1, y1 = y0, x0, y1, x1
return [x0, y0, x1 - x0, y1 - y0]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[([5, 6], 8, [-2, 0, 4, 1]), [0, 3, 1, 2]], [([2, 7], 7, [1, 6, 3, 3]), [0, 0, 1, 1]], [([5, 1], 6, [-3, -2, 5, 4]), [0, 0, 1, 2]], [([7, 5], 1, [6, -1, 4, 0]), None], [([3, 4], 3, [-2, 3, 0, 2]), None], [([2, 4], 8, [2, 1, 3, 3]), None], [([2, 4], 7, [1, -3, 3, 3]), None], [([4, 1], 7, [-2, -2, 3, 5]), [0, 3, 1, 1]]], [[([6, 4], 3, [-2, 2, 5, 5]), [3, 0, 3, 2]], [([1, 4], 3, [0, -3, 3, 5]), [0, 2, 1, 2]], [([3, 5], 0, [-3, -2, 2, 4]), None], [([3, 1], 1, [2, 2, 2, 0]), None], [([4, 1], 3, [6, 3, 2, 4]), None], [([5, 5], 6, [6, 3, 5, 0]), None], [([4, 5], 1, [1, 2, 5, 4]), [1, 2, 3, 3]], [([7, 7], 8, [2, 1, 5, 3]), [1, 0, 3, 5]]], [[([2, 2], 2, [1, 0, 5, 4]), [0, 0, 1, 2]], [([6, 4], 2, [2, -2, 1, 4]), [3, 0, 1, 2]], [([4, 5], 8, [2, -2, 0, 2]), None], [([6, 4], 6, [2, 1, 3, 4]), [0, 2, 3, 3]], [([1, 5], 9, [2, 3, 4, 4]), None], [([6, 1], 2, [2, 1, 3, 0]), None], [([1, 2], 9, [-2, 1, 1, 3]), None], [([5, 2], 8, [1, 1, 5, 1]), [1, 0, 1, 4]]], [[([4, 4], 7, [1, 2, 5, 5]), [0, 0, 2, 3]], [([6, 2], 2, [-1, 1, 5, 5]), [2, 1, 4, 1]], [([3, 7], 7, [-1, 6, 2, 0]), None], [([3, 6], 8, [6, -2, 2, 3]), None], [([7, 7], 2, [-2, 0, 0, 4]), None], [([2, 5], 1, [1, 6, 5, 2]), None], [([5, 5], 1, [6, 1, 5, 4]), None], [([7, 5], 8, [0, 4, 5, 5]), [4, 2, 1, 5]]], [[([7, 6], 8, [3, 2, 3, 2]), [2, 1, 2, 3]], [([2, 6], 7, [-3, 3, 4, 5]), [0, 1, 3, 1]], [([1, 1], 7, [1, -3, 2, 0]), None], [([4, 5], 6, [1, 3, 0, 5]), None], [([4, 1], 0, [2, 4, 5, 5]), None], [([6, 7], 7, [6, 0, 3, 1]), None], [([2, 4], 3, [5, 0, 1, 5]), None], [([7, 1], 7, [0, -2, 5, 4]), [0, 2, 1, 5]]]]
labels = ["regression: half-open horizontal mirror", "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: half-open horizontal mirror 0 | [0, 5, 1, -2] | [0, 3, 1, 2] | Failed |
| repair trap 1 | [0, 1, 1, -1] | [0, 0, 1, 1] | Failed |
| combined fault 2 | [0, 0, 1, 2] | [0, 0, 1, 2] | Passed |
| control 3 | None | None | Passed |
| control 4 | None | None | Passed |
| boundary 5 | None | None | Passed |
| boundary 6 | None | None | Passed |
| control 7 | [0, 4, 1, -1] | [0, 3, 1, 1] | Failed |
SHA-256 / fa52ed39f9948647e6f1df4e960ca50972dcce8ec613b603a9c389801e8edcce
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(size, tag, box):
w, h = size
x0, y0, bw, bh = box
x1 = min(x0 + bw, w)
y1 = min(y0 + bh, h)
x0 = max(x0, 0)
y0 = max(y0, 0)
if x1 <= x0 or y1 <= y0:
return None
table = {1: (0, 0, 0), 2: (1, 0, 0), 3: (1, 1, 0), 4: (0, 1, 0), 5: (0, 0, 1), 6: (0, 1, 1), 7: (1, 1, 1), 8: (1, 0, 1)}
if tag not in table:
return None
fx, fy, tr = table[tag]
if fx:
x0, x1 = w - x1, w - x0
if fy:
y0, y1 = h - y1, h - y0
if tr:
x0, y0, x1, y1 = y0, x0, y1, x1
return [x0, y0, x1 - x0, y1 - y0]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[([5, 6], 8, [-2, 0, 4, 1]), [0, 3, 1, 2]], [([2, 7], 7, [1, 6, 3, 3]), [0, 0, 1, 1]], [([5, 1], 6, [-3, -2, 5, 4]), [0, 0, 1, 2]], [([7, 5], 1, [6, -1, 4, 0]), None], [([3, 4], 3, [-2, 3, 0, 2]), None], [([2, 4], 8, [2, 1, 3, 3]), None], [([2, 4], 7, [1, -3, 3, 3]), None], [([4, 1], 7, [-2, -2, 3, 5]), [0, 3, 1, 1]]], [[([6, 4], 3, [-2, 2, 5, 5]), [3, 0, 3, 2]], [([1, 4], 3, [0, -3, 3, 5]), [0, 2, 1, 2]], [([3, 5], 0, [-3, -2, 2, 4]), None], [([3, 1], 1, [2, 2, 2, 0]), None], [([4, 1], 3, [6, 3, 2, 4]), None], [([5, 5], 6, [6, 3, 5, 0]), None], [([4, 5], 1, [1, 2, 5, 4]), [1, 2, 3, 3]], [([7, 7], 8, [2, 1, 5, 3]), [1, 0, 3, 5]]], [[([2, 2], 2, [1, 0, 5, 4]), [0, 0, 1, 2]], [([6, 4], 2, [2, -2, 1, 4]), [3, 0, 1, 2]], [([4, 5], 8, [2, -2, 0, 2]), None], [([6, 4], 6, [2, 1, 3, 4]), [0, 2, 3, 3]], [([1, 5], 9, [2, 3, 4, 4]), None], [([6, 1], 2, [2, 1, 3, 0]), None], [([1, 2], 9, [-2, 1, 1, 3]), None], [([5, 2], 8, [1, 1, 5, 1]), [1, 0, 1, 4]]], [[([4, 4], 7, [1, 2, 5, 5]), [0, 0, 2, 3]], [([6, 2], 2, [-1, 1, 5, 5]), [2, 1, 4, 1]], [([3, 7], 7, [-1, 6, 2, 0]), None], [([3, 6], 8, [6, -2, 2, 3]), None], [([7, 7], 2, [-2, 0, 0, 4]), None], [([2, 5], 1, [1, 6, 5, 2]), None], [([5, 5], 1, [6, 1, 5, 4]), None], [([7, 5], 8, [0, 4, 5, 5]), [4, 2, 1, 5]]], [[([7, 6], 8, [3, 2, 3, 2]), [2, 1, 2, 3]], [([2, 6], 7, [-3, 3, 4, 5]), [0, 1, 3, 1]], [([1, 1], 7, [1, -3, 2, 0]), None], [([4, 5], 6, [1, 3, 0, 5]), None], [([4, 1], 0, [2, 4, 5, 5]), None], [([6, 7], 7, [6, 0, 3, 1]), None], [([2, 4], 3, [5, 0, 1, 5]), None], [([7, 1], 7, [0, -2, 5, 4]), [0, 2, 1, 5]]]]
labels = ["regression: half-open horizontal mirror", "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: half-open horizontal mirror 0 | [0, 3, 1, 2] | [0, 3, 1, 2] | Passed |
| repair trap 1 | [0, 0, 1, 1] | [0, 0, 1, 1] | Passed |
| combined fault 2 | [0, 0, 1, 2] | [0, 0, 1, 2] | Passed |
| control 3 | None | None | Passed |
| control 4 | None | None | Passed |
| boundary 5 | None | None | Passed |
| boundary 6 | None | None | Passed |
| control 7 | [0, 3, 1, 1] | [0, 3, 1, 1] | Passed |
SHA-256 / 0b4421adbe6347660c4843f305da04de90402dee076096b0b523cd5dadb7982d
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.291632+00:00.
Case digest / 4458d5686061cd8f51a2e5cecf160365413b1f76290b8027f101ba08a5eea266