FAILURE MAP
← Case archive

FA-79271 / Image orientation metadata / Open access

Tap mapping assumes cover fit · case 01

Taps near the letterbox bars map to pixels that are not on screen.

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

ROOT CAUSE

The scale uses the larger ratio (cover), but the viewer uses contain.

VERIFIED REPAIR

Use the smaller ratio so the whole image fits.

Unsuccessful approach: Fitting only to the view width overflows tall images.

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 = max(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 = [[[([40, 25], [5, 4], 8, [32, 13]), None], [([32, 19], [6, 3], 8, [7, 6]), None], [([36, 10], [2, 9], 1, [36, 0]), None], [([20, 22], [9, 8], 8, [11, 3]), [7, 4]], [([38, 22], [9, 5], 4, [20, 12]), [4, 2]], [([11, 9], [3, 2], 6, [11, 2]), None], [([38, 23], [5, 8], 6, [12, 1]), [0, 5]], [([35, 16], [9, 2], 5, [3, 11]), None]], [[([40, 21], [2, 9], 3, [13, 12]), None], [([22, 39], [2, 9], 4, [16, 1]), None], [([29, 40], [2, 5], 3, [22, 11]), [0, 3]], [([17, 18], [6, 7], 3, [1, 6]), [5, 4]], [([14, 32], [7, 4], 7, [8, 32]), None], [([24, 14], [5, 8], 5, [7, 8]), [2, 2]], [([8, 33], [6, 2], 8, [3, 15]), [3, 0]], [([25, 26], [2, 9], 6, [18, 0]), None]], [[([11, 19], [8, 2], 8, [8, 11]), None], [([17, 21], [6, 3], 5, [7, 3]), [0, 1]], [([27, 38], [2, 7], 4, [5, 7]), None], [([15, 28], [7, 3], 6, [4, 18]), [4, 2]], [([35, 28], [3, 2], 6, [23, 18]), [1, 0]], [([33, 14], [4, 7], 7, [20, 5]), [2, 2]], [([8, 17], [2, 4], 1, [0, 11]), [0, 2]], [([10, 14], [2, 8], 6, [3, 6]), [0, 5]]], [[([22, 29], [9, 2], 3, [8, 26]), None], [([33, 29], [4, 8], 2, [22, 8]), [0, 2]], [([23, 17], [8, 8], 4, [2, 11]), None], [([33, 38], [9, 9], 4, [12, 18]), [3, 4]], [([39, 38], [3, 2], 2, [30, 38]), None], [([21, 27], [7, 5], 7, [12, 2]), [6, 2]], [([12, 23], [5, 9], 1, [9, 2]), [3, 0]], [([35, 33], [4, 8], 3, [8, 22]), None]], [[([29, 29], [7, 9], 8, [12, 2]), None], [([24, 8], [4, 7], 8, [16, 3]), [2, 5]], [([15, 35], [8, 2], 5, [2, 15]), None], [([18, 21], [2, 4], 6, [13, 6]), [0, 1]], [([39, 35], [7, 7], 4, [15, 9]), [2, 5]], [([26, 16], [5, 6], 7, [22, 12]), [1, 0]], [([39, 29], [4, 8], 6, [11, 19]), [2, 5]], [([14, 27], [3, 9], 3, [3, 26]), [2, 0]]]]
labels = ["regression: contain versus cover scale", "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: contain versus cover scale 0[2, 3]NoneFailed
repair trap 1[3, 0]NoneFailed
combined fault 2NoneNonePassed
control 3[7, 4][7, 4]Passed
control 4[4, 2][4, 2]Passed
boundary 5NoneNonePassed
boundary 6[0, 5][0, 5]Passed
control 7[4, 0]NoneFailed

SHA-256 / d98798cc2f42040607222fb2ebaf8c2cf498347a53998eef5967f255d5159157

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 = Fraction(vw, dw)
    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 = [[[([40, 25], [5, 4], 8, [32, 13]), None], [([32, 19], [6, 3], 8, [7, 6]), None], [([36, 10], [2, 9], 1, [36, 0]), None], [([20, 22], [9, 8], 8, [11, 3]), [7, 4]], [([38, 22], [9, 5], 4, [20, 12]), [4, 2]], [([11, 9], [3, 2], 6, [11, 2]), None], [([38, 23], [5, 8], 6, [12, 1]), [0, 5]], [([35, 16], [9, 2], 5, [3, 11]), None]], [[([40, 21], [2, 9], 3, [13, 12]), None], [([22, 39], [2, 9], 4, [16, 1]), None], [([29, 40], [2, 5], 3, [22, 11]), [0, 3]], [([17, 18], [6, 7], 3, [1, 6]), [5, 4]], [([14, 32], [7, 4], 7, [8, 32]), None], [([24, 14], [5, 8], 5, [7, 8]), [2, 2]], [([8, 33], [6, 2], 8, [3, 15]), [3, 0]], [([25, 26], [2, 9], 6, [18, 0]), None]], [[([11, 19], [8, 2], 8, [8, 11]), None], [([17, 21], [6, 3], 5, [7, 3]), [0, 1]], [([27, 38], [2, 7], 4, [5, 7]), None], [([15, 28], [7, 3], 6, [4, 18]), [4, 2]], [([35, 28], [3, 2], 6, [23, 18]), [1, 0]], [([33, 14], [4, 7], 7, [20, 5]), [2, 2]], [([8, 17], [2, 4], 1, [0, 11]), [0, 2]], [([10, 14], [2, 8], 6, [3, 6]), [0, 5]]], [[([22, 29], [9, 2], 3, [8, 26]), None], [([33, 29], [4, 8], 2, [22, 8]), [0, 2]], [([23, 17], [8, 8], 4, [2, 11]), None], [([33, 38], [9, 9], 4, [12, 18]), [3, 4]], [([39, 38], [3, 2], 2, [30, 38]), None], [([21, 27], [7, 5], 7, [12, 2]), [6, 2]], [([12, 23], [5, 9], 1, [9, 2]), [3, 0]], [([35, 33], [4, 8], 3, [8, 22]), None]], [[([29, 29], [7, 9], 8, [12, 2]), None], [([24, 8], [4, 7], 8, [16, 3]), [2, 5]], [([15, 35], [8, 2], 5, [2, 15]), None], [([18, 21], [2, 4], 6, [13, 6]), [0, 1]], [([39, 35], [7, 7], 4, [15, 9]), [2, 5]], [([26, 16], [5, 6], 7, [22, 12]), [1, 0]], [([39, 29], [4, 8], 6, [11, 19]), [2, 5]], [([14, 27], [3, 9], 3, [3, 26]), [2, 0]]]]
labels = ["regression: contain versus cover scale", "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: contain versus cover scale 0[2, 3]NoneFailed
repair trap 1[3, 0]NoneFailed
combined fault 2NoneNonePassed
control 3[7, 4][7, 4]Passed
control 4[4, 2][4, 2]Passed
boundary 5NoneNonePassed
boundary 6[0, 5][0, 5]Passed
control 7[4, 0]NoneFailed

SHA-256 / 4150b671c83b619e25fda804b0243e98929c5d8923df23eac35354b98411e1b4

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 = [[[([40, 25], [5, 4], 8, [32, 13]), None], [([32, 19], [6, 3], 8, [7, 6]), None], [([36, 10], [2, 9], 1, [36, 0]), None], [([20, 22], [9, 8], 8, [11, 3]), [7, 4]], [([38, 22], [9, 5], 4, [20, 12]), [4, 2]], [([11, 9], [3, 2], 6, [11, 2]), None], [([38, 23], [5, 8], 6, [12, 1]), [0, 5]], [([35, 16], [9, 2], 5, [3, 11]), None]], [[([40, 21], [2, 9], 3, [13, 12]), None], [([22, 39], [2, 9], 4, [16, 1]), None], [([29, 40], [2, 5], 3, [22, 11]), [0, 3]], [([17, 18], [6, 7], 3, [1, 6]), [5, 4]], [([14, 32], [7, 4], 7, [8, 32]), None], [([24, 14], [5, 8], 5, [7, 8]), [2, 2]], [([8, 33], [6, 2], 8, [3, 15]), [3, 0]], [([25, 26], [2, 9], 6, [18, 0]), None]], [[([11, 19], [8, 2], 8, [8, 11]), None], [([17, 21], [6, 3], 5, [7, 3]), [0, 1]], [([27, 38], [2, 7], 4, [5, 7]), None], [([15, 28], [7, 3], 6, [4, 18]), [4, 2]], [([35, 28], [3, 2], 6, [23, 18]), [1, 0]], [([33, 14], [4, 7], 7, [20, 5]), [2, 2]], [([8, 17], [2, 4], 1, [0, 11]), [0, 2]], [([10, 14], [2, 8], 6, [3, 6]), [0, 5]]], [[([22, 29], [9, 2], 3, [8, 26]), None], [([33, 29], [4, 8], 2, [22, 8]), [0, 2]], [([23, 17], [8, 8], 4, [2, 11]), None], [([33, 38], [9, 9], 4, [12, 18]), [3, 4]], [([39, 38], [3, 2], 2, [30, 38]), None], [([21, 27], [7, 5], 7, [12, 2]), [6, 2]], [([12, 23], [5, 9], 1, [9, 2]), [3, 0]], [([35, 33], [4, 8], 3, [8, 22]), None]], [[([29, 29], [7, 9], 8, [12, 2]), None], [([24, 8], [4, 7], 8, [16, 3]), [2, 5]], [([15, 35], [8, 2], 5, [2, 15]), None], [([18, 21], [2, 4], 6, [13, 6]), [0, 1]], [([39, 35], [7, 7], 4, [15, 9]), [2, 5]], [([26, 16], [5, 6], 7, [22, 12]), [1, 0]], [([39, 29], [4, 8], 6, [11, 19]), [2, 5]], [([14, 27], [3, 9], 3, [3, 26]), [2, 0]]]]
labels = ["regression: contain versus cover scale", "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: contain versus cover scale 0NoneNonePassed
repair trap 1NoneNonePassed
combined fault 2NoneNonePassed
control 3[7, 4][7, 4]Passed
control 4[4, 2][4, 2]Passed
boundary 5NoneNonePassed
boundary 6[0, 5][0, 5]Passed
control 7NoneNonePassed

SHA-256 / 127dcd8fa500374a2aa72f7af0cd29ec70c394856a31c879a3c38da9faff2d61

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

Case digest / dbf4ac189ad8b20bae985d130c22522a052b10be5bef04600266fd595c52f7c9