FAILURE MAP
← Case archive

FA-79281 / Image orientation metadata / Open access

Tap position is rounded to the nearest pixel corner · case 01

Taps in the right half of a pixel select its neighbour.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The continuous position is rounded instead of floored.

VERIFIED REPAIR

Floor the continuous display position to get the pixel index.

Unsuccessful approach: ceil - 1 maps a tap exactly on a pixel boundary to the previous pixel.

Case contract

A viewer letterboxes the displayed image (contain fit, centred) inside a view [vw, vh]. Map a tap [tx, ty] in view coordinates to the stored pixel [x, y] of an image of stored size [w, h] with orientation tag 1..8 (invalid -> 1); tags 5..8 swap displayed axes. Taps in the letterbox bars or on the far edge return None; the displayed pixel is floor of the exact position, then mapped back through the inverse of the orientation.

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
import math
from fractions import Fraction
N = 1
observations = []
def solve(view, size, tag, tap):
    vw, vh = view
    w, h = size
    tx, ty = tap
    if tag not in range(1, 9):
        tag = 1
    dw, dh = (h, w) if tag >= 5 else (w, h)
    s = min(Fraction(vw, dw), Fraction(vh, dh))
    ox = (vw - dw * s) / 2
    oy = (vh - dh * s) / 2
    dx = (tx - ox) / s
    dy = (ty - oy) / s
    if dx < 0 or dy < 0 or dx >= dw or dy >= dh:
        return None
    px, py = round(dx), round(dy)
    if tag == 1:
        return [px, py]
    if tag == 2:
        return [w - 1 - px, py]
    if tag == 3:
        return [w - 1 - px, h - 1 - py]
    if tag == 4:
        return [px, h - 1 - py]
    if tag == 5:
        return [py, px]
    if tag == 6:
        return [py, h - 1 - px]
    if tag == 7:
        return [w - 1 - py, h - 1 - px]
    return [w - 1 - py, px]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[([17, 19], [3, 9], 1, [7, 11]), [0, 5]], [([19, 9], [3, 5], 6, [5, 4]), [1, 3]], [([9, 8], [6, 2], 2, [3, 5]), [3, 1]], [([40, 25], [5, 4], 8, [32, 13]), None], [([35, 16], [9, 2], 5, [3, 11]), None], [([13, 34], [5, 3], 1, [10, 31]), None], [([13, 26], [7, 5], 8, [9, 3]), None], [([18, 19], [5, 7], 4, [10, 11]), [2, 2]]], [[([29, 40], [2, 5], 3, [22, 11]), [0, 3]], [([34, 20], [5, 5], 1, [18, 16]), [2, 4]], [([34, 33], [9, 7], 5, [15, 22]), [6, 2]], [([40, 21], [2, 9], 3, [13, 12]), None], [([25, 26], [2, 9], 6, [18, 0]), None], [([21, 19], [8, 6], 3, [19, 2]), [0, 5]], [([17, 18], [6, 7], 3, [1, 6]), [5, 4]], [([36, 27], [4, 5], 3, [22, 3]), [1, 4]]], [[([17, 21], [6, 3], 5, [7, 3]), [0, 1]], [([8, 14], [3, 5], 4, [0, 5]), [0, 3]], [([40, 37], [2, 7], 6, [0, 22]), [1, 6]], [([35, 17], [7, 6], 1, [31, 5]), None], [([22, 15], [4, 6], 7, [16, 2]), [3, 1]], [([29, 33], [4, 5], 5, [5, 29]), None], [([37, 32], [8, 3], 3, [9, 25]), None], [([17, 38], [4, 3], 4, [2, 16]), [0, 2]]], [[([19, 25], [6, 8], 2, [5, 18]), [4, 5]], [([28, 27], [9, 4], 7, [12, 3]), [7, 2]], [([9, 38], [8, 3], 8, [2, 16]), [4, 0]], [([22, 29], [9, 2], 3, [8, 26]), None], [([35, 16], [3, 9], 2, [10, 1]), None], [([20, 23], [3, 9], 0, [20, 12]), None], [([29, 39], [9, 2], 8, [0, 36]), None], [([10, 8], [6, 8], 8, [6, 2]), [4, 4]]], [[([24, 8], [4, 7], 8, [16, 3]), [2, 5]], [([15, 24], [4, 3], 7, [12, 2]), [3, 0]], [([12, 29], [7, 4], 7, [9, 15]), [3, 0]], [([29, 29], [7, 9], 8, [12, 2]), None], [([36, 16], [8, 2], 3, [32, 16]), None], [([16, 18], [3, 4], 0, [6, 14]), [1, 3]], [([33, 36], [7, 2], 0, [24, 19]), [5, 1]], [([14, 27], [3, 9], 3, [3, 26]), [2, 0]]]]
labels = ["regression: displayed pixel quantisation", "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 fixtureActualExpectedOutcome
regression: displayed pixel quantisation 0[1, 5][0, 5]Failed
repair trap 1[1, 3][1, 3]Passed
combined fault 2[3, 2][3, 1]Failed
control 3NoneNonePassed
control 4NoneNonePassed
boundary 5NoneNonePassed
boundary 6NoneNonePassed
control 7[3, 2][2, 2]Failed

SHA-256 / 2736288f30d131522d8da9444b36c9dc2303346bb04ee3dda79117044e709281

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(view, size, tag, tap):
    vw, vh = view
    w, h = size
    tx, ty = tap
    if tag not in range(1, 9):
        tag = 1
    dw, dh = (h, w) if tag >= 5 else (w, h)
    s = min(Fraction(vw, dw), Fraction(vh, dh))
    ox = (vw - dw * s) / 2
    oy = (vh - dh * s) / 2
    dx = (tx - ox) / s
    dy = (ty - oy) / s
    if dx < 0 or dy < 0 or dx >= dw or dy >= dh:
        return None
    px, py = math.ceil(dx) - 1, math.ceil(dy) - 1
    if tag == 1:
        return [px, py]
    if tag == 2:
        return [w - 1 - px, py]
    if tag == 3:
        return [w - 1 - px, h - 1 - py]
    if tag == 4:
        return [px, h - 1 - py]
    if tag == 5:
        return [py, px]
    if tag == 6:
        return [py, h - 1 - px]
    if tag == 7:
        return [w - 1 - py, h - 1 - px]
    return [w - 1 - py, px]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[([17, 19], [3, 9], 1, [7, 11]), [0, 5]], [([19, 9], [3, 5], 6, [5, 4]), [1, 3]], [([9, 8], [6, 2], 2, [3, 5]), [3, 1]], [([40, 25], [5, 4], 8, [32, 13]), None], [([35, 16], [9, 2], 5, [3, 11]), None], [([13, 34], [5, 3], 1, [10, 31]), None], [([13, 26], [7, 5], 8, [9, 3]), None], [([18, 19], [5, 7], 4, [10, 11]), [2, 2]]], [[([29, 40], [2, 5], 3, [22, 11]), [0, 3]], [([34, 20], [5, 5], 1, [18, 16]), [2, 4]], [([34, 33], [9, 7], 5, [15, 22]), [6, 2]], [([40, 21], [2, 9], 3, [13, 12]), None], [([25, 26], [2, 9], 6, [18, 0]), None], [([21, 19], [8, 6], 3, [19, 2]), [0, 5]], [([17, 18], [6, 7], 3, [1, 6]), [5, 4]], [([36, 27], [4, 5], 3, [22, 3]), [1, 4]]], [[([17, 21], [6, 3], 5, [7, 3]), [0, 1]], [([8, 14], [3, 5], 4, [0, 5]), [0, 3]], [([40, 37], [2, 7], 6, [0, 22]), [1, 6]], [([35, 17], [7, 6], 1, [31, 5]), None], [([22, 15], [4, 6], 7, [16, 2]), [3, 1]], [([29, 33], [4, 5], 5, [5, 29]), None], [([37, 32], [8, 3], 3, [9, 25]), None], [([17, 38], [4, 3], 4, [2, 16]), [0, 2]]], [[([19, 25], [6, 8], 2, [5, 18]), [4, 5]], [([28, 27], [9, 4], 7, [12, 3]), [7, 2]], [([9, 38], [8, 3], 8, [2, 16]), [4, 0]], [([22, 29], [9, 2], 3, [8, 26]), None], [([35, 16], [3, 9], 2, [10, 1]), None], [([20, 23], [3, 9], 0, [20, 12]), None], [([29, 39], [9, 2], 8, [0, 36]), None], [([10, 8], [6, 8], 8, [6, 2]), [4, 4]]], [[([24, 8], [4, 7], 8, [16, 3]), [2, 5]], [([15, 24], [4, 3], 7, [12, 2]), [3, 0]], [([12, 29], [7, 4], 7, [9, 15]), [3, 0]], [([29, 29], [7, 9], 8, [12, 2]), None], [([36, 16], [8, 2], 3, [32, 16]), None], [([16, 18], [3, 4], 0, [6, 14]), [1, 3]], [([33, 36], [7, 2], 0, [24, 19]), [5, 1]], [([14, 27], [3, 9], 3, [3, 26]), [2, 0]]]]
labels = ["regression: displayed pixel quantisation", "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 fixtureActualExpectedOutcome
regression: displayed pixel quantisation 0[0, 5][0, 5]Passed
repair trap 1[1, 4][1, 3]Failed
combined fault 2[4, 1][3, 1]Failed
control 3NoneNonePassed
control 4NoneNonePassed
boundary 5NoneNonePassed
boundary 6NoneNonePassed
control 7[2, 2][2, 2]Passed

SHA-256 / 70e3ca296f511766224ea39fc4b09a775010e45152bb55b5f40be11dad8c861e

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(view, size, tag, tap):
    vw, vh = view
    w, h = size
    tx, ty = tap
    if tag not in range(1, 9):
        tag = 1
    dw, dh = (h, w) if tag >= 5 else (w, h)
    s = min(Fraction(vw, dw), Fraction(vh, dh))
    ox = (vw - dw * s) / 2
    oy = (vh - dh * s) / 2
    dx = (tx - ox) / s
    dy = (ty - oy) / s
    if dx < 0 or dy < 0 or dx >= dw or dy >= dh:
        return None
    px, py = math.floor(dx), math.floor(dy)
    if tag == 1:
        return [px, py]
    if tag == 2:
        return [w - 1 - px, py]
    if tag == 3:
        return [w - 1 - px, h - 1 - py]
    if tag == 4:
        return [px, h - 1 - py]
    if tag == 5:
        return [py, px]
    if tag == 6:
        return [py, h - 1 - px]
    if tag == 7:
        return [w - 1 - py, h - 1 - px]
    return [w - 1 - py, px]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[([17, 19], [3, 9], 1, [7, 11]), [0, 5]], [([19, 9], [3, 5], 6, [5, 4]), [1, 3]], [([9, 8], [6, 2], 2, [3, 5]), [3, 1]], [([40, 25], [5, 4], 8, [32, 13]), None], [([35, 16], [9, 2], 5, [3, 11]), None], [([13, 34], [5, 3], 1, [10, 31]), None], [([13, 26], [7, 5], 8, [9, 3]), None], [([18, 19], [5, 7], 4, [10, 11]), [2, 2]]], [[([29, 40], [2, 5], 3, [22, 11]), [0, 3]], [([34, 20], [5, 5], 1, [18, 16]), [2, 4]], [([34, 33], [9, 7], 5, [15, 22]), [6, 2]], [([40, 21], [2, 9], 3, [13, 12]), None], [([25, 26], [2, 9], 6, [18, 0]), None], [([21, 19], [8, 6], 3, [19, 2]), [0, 5]], [([17, 18], [6, 7], 3, [1, 6]), [5, 4]], [([36, 27], [4, 5], 3, [22, 3]), [1, 4]]], [[([17, 21], [6, 3], 5, [7, 3]), [0, 1]], [([8, 14], [3, 5], 4, [0, 5]), [0, 3]], [([40, 37], [2, 7], 6, [0, 22]), [1, 6]], [([35, 17], [7, 6], 1, [31, 5]), None], [([22, 15], [4, 6], 7, [16, 2]), [3, 1]], [([29, 33], [4, 5], 5, [5, 29]), None], [([37, 32], [8, 3], 3, [9, 25]), None], [([17, 38], [4, 3], 4, [2, 16]), [0, 2]]], [[([19, 25], [6, 8], 2, [5, 18]), [4, 5]], [([28, 27], [9, 4], 7, [12, 3]), [7, 2]], [([9, 38], [8, 3], 8, [2, 16]), [4, 0]], [([22, 29], [9, 2], 3, [8, 26]), None], [([35, 16], [3, 9], 2, [10, 1]), None], [([20, 23], [3, 9], 0, [20, 12]), None], [([29, 39], [9, 2], 8, [0, 36]), None], [([10, 8], [6, 8], 8, [6, 2]), [4, 4]]], [[([24, 8], [4, 7], 8, [16, 3]), [2, 5]], [([15, 24], [4, 3], 7, [12, 2]), [3, 0]], [([12, 29], [7, 4], 7, [9, 15]), [3, 0]], [([29, 29], [7, 9], 8, [12, 2]), None], [([36, 16], [8, 2], 3, [32, 16]), None], [([16, 18], [3, 4], 0, [6, 14]), [1, 3]], [([33, 36], [7, 2], 0, [24, 19]), [5, 1]], [([14, 27], [3, 9], 3, [3, 26]), [2, 0]]]]
labels = ["regression: displayed pixel quantisation", "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 fixtureActualExpectedOutcome
regression: displayed pixel quantisation 0[0, 5][0, 5]Passed
repair trap 1[1, 3][1, 3]Passed
combined fault 2[3, 1][3, 1]Passed
control 3NoneNonePassed
control 4NoneNonePassed
boundary 5NoneNonePassed
boundary 6NoneNonePassed
control 7[2, 2][2, 2]Passed

SHA-256 / f8ae0968867c6fb63549c1fd040a9f2f26851f7ea735e5d367f36b2ade8e08b1

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:43.140137+00:00.

Case digest / f4b503c16fb206bb122dee48e15a9da3560330ade42349caa807d43cac1020c6