FA-79066 / Image orientation metadata / Open access
Height is trimmed for horizontal flips instead of vertical ones · case 01
Clockwise-rotated photos keep a partial bottom MCU row that ends up as a garbage left column.
ROOT CAUSE
The height trim is keyed on the horizontal flip flag.
VERIFIED REPAIR
Trim the height exactly when the decomposition flips vertically in stored space.
Unsuccessful approach: Trimming for every transposing tag also trims transpose (5), which moves no partial block to a leading edge.
Case contract
Input [w, h, tag, sampling]. A lossless JPEG transform that bakes the orientation can only move whole MCUs (444: 8x8, 422: 16 wide x 8 high, 420: 16x16, 440: 8 wide x 16 high), so any partial MCU column or row that would move to the leading edge is trimmed. The tag decomposes into stored-space flips (fx, fy) followed by an optional transpose; fx trims the width and fy trims the height to a multiple of the MCU size. Invalid tags are treated as 1. Return the displayed [width, height], "refuse" when a trimmed side becomes 0, or "unknown-sampling".
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(x):
w, h, tag, sampling = x
mcu = {'444': (8, 8), '422': (16, 8), '420': (16, 16), '440': (8, 16)}
if sampling not in mcu:
return 'unknown-sampling'
mw, mh = mcu[sampling]
flips = {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)}
fx, fy, tr = flips.get(tag, (0, 0, 0))
tw = w - w % mw if fx else w
th = h - h % mh if fx else h
if tw == 0 or th == 0:
return 'refuse'
if tr:
tw, th = th, tw
return [tw, th]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[8, 8, 4, '440'], 'refuse'], [[16, 170, 8, '420'], [170, 16]], [[8, 8, 8, '440'], [8, 8]], [[24, 12, 0, '440'], [24, 12]], [[2969, 96, 1, '422'], [2969, 96]], [[24, 16, 5, '422'], [16, 24]], [[40, 2600, 0, '440'], [40, 2600]], [[24, 12, 6, '444'], [8, 24]]], [[[25, 8, 8, '420'], [8, 16]], [[2388, 13, 5, '420'], [13, 2388]], [[8, 12, 8, '440'], [12, 8]], [[8, 12, 1, '411'], 'unknown-sampling'], [[8, 2948, 7, '422'], 'refuse'], [[24, 24, 0, '422'], [24, 24]], [[16, 16, 6, '444'], [16, 16]], [[24, 24, 2, '440'], [24, 24]]], [[[8, 8, 6, '440'], 'refuse'], [[8, 12, 5, '422'], [12, 8]], [[24, 20, 8, '422'], [20, 16]], [[12, 12, 3, '420'], 'refuse'], [[24, 24, 0, '420'], [24, 24]], [[40, 24, 0, '422'], [40, 24]], [[865, 24, 5, '422'], [24, 865]], [[24, 12, 6, '422'], [8, 24]]], [[[24, 24, 4, '420'], [24, 16]], [[40, 58, 8, '422'], [58, 32]], [[40, 12, 8, '422'], [12, 32]], [[16, 272, 4, '422'], [16, 272]], [[24, 16, 6, '440'], [16, 24]], [[55, 16, 6, '440'], [16, 55]], [[24, 4, 3, '422'], 'refuse'], [[24, 12, 6, '420'], 'refuse']], [[[1545, 12, 6, '422'], [8, 1545]], [[12, 20, 8, '440'], [20, 8]], [[40, 20, 8, '440'], [20, 40]], [[8, 688, 2, '420'], 'refuse'], [[24, 8, 6, '422'], [8, 24]], [[8, 67, 7, '444'], [64, 8]], [[16, 24, 2, '411'], 'unknown-sampling'], [[8, 1190, 6, '444'], [1184, 8]]]]
labels = ["regression: height trim condition", "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: height trim condition 0 | [8, 8] | refuse | Failed |
| repair trap 1 | [160, 16] | [170, 16] | Failed |
| combined fault 2 | refuse | [8, 8] | Failed |
| control 3 | [24, 12] | [24, 12] | Passed |
| control 4 | [2969, 96] | [2969, 96] | Passed |
| boundary 5 | [16, 24] | [16, 24] | Passed |
| boundary 6 | [40, 2600] | [40, 2600] | Passed |
| control 7 | [12, 24] | [8, 24] | Failed |
SHA-256 / f5c5b6f90805090973210c3959698af92ded30517a5ed439662526092265bb7c
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
w, h, tag, sampling = x
mcu = {'444': (8, 8), '422': (16, 8), '420': (16, 16), '440': (8, 16)}
if sampling not in mcu:
return 'unknown-sampling'
mw, mh = mcu[sampling]
flips = {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)}
fx, fy, tr = flips.get(tag, (0, 0, 0))
tw = w - w % mw if fx else w
th = h - h % mh if (fy or tr) else h
if tw == 0 or th == 0:
return 'refuse'
if tr:
tw, th = th, tw
return [tw, th]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[8, 8, 4, '440'], 'refuse'], [[16, 170, 8, '420'], [170, 16]], [[8, 8, 8, '440'], [8, 8]], [[24, 12, 0, '440'], [24, 12]], [[2969, 96, 1, '422'], [2969, 96]], [[24, 16, 5, '422'], [16, 24]], [[40, 2600, 0, '440'], [40, 2600]], [[24, 12, 6, '444'], [8, 24]]], [[[25, 8, 8, '420'], [8, 16]], [[2388, 13, 5, '420'], [13, 2388]], [[8, 12, 8, '440'], [12, 8]], [[8, 12, 1, '411'], 'unknown-sampling'], [[8, 2948, 7, '422'], 'refuse'], [[24, 24, 0, '422'], [24, 24]], [[16, 16, 6, '444'], [16, 16]], [[24, 24, 2, '440'], [24, 24]]], [[[8, 8, 6, '440'], 'refuse'], [[8, 12, 5, '422'], [12, 8]], [[24, 20, 8, '422'], [20, 16]], [[12, 12, 3, '420'], 'refuse'], [[24, 24, 0, '420'], [24, 24]], [[40, 24, 0, '422'], [40, 24]], [[865, 24, 5, '422'], [24, 865]], [[24, 12, 6, '422'], [8, 24]]], [[[24, 24, 4, '420'], [24, 16]], [[40, 58, 8, '422'], [58, 32]], [[40, 12, 8, '422'], [12, 32]], [[16, 272, 4, '422'], [16, 272]], [[24, 16, 6, '440'], [16, 24]], [[55, 16, 6, '440'], [16, 55]], [[24, 4, 3, '422'], 'refuse'], [[24, 12, 6, '420'], 'refuse']], [[[1545, 12, 6, '422'], [8, 1545]], [[12, 20, 8, '440'], [20, 8]], [[40, 20, 8, '440'], [20, 40]], [[8, 688, 2, '420'], 'refuse'], [[24, 8, 6, '422'], [8, 24]], [[8, 67, 7, '444'], [64, 8]], [[16, 24, 2, '411'], 'unknown-sampling'], [[8, 1190, 6, '444'], [1184, 8]]]]
labels = ["regression: height trim condition", "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: height trim condition 0 | refuse | refuse | Passed |
| repair trap 1 | [160, 16] | [170, 16] | Failed |
| combined fault 2 | refuse | [8, 8] | Failed |
| control 3 | [24, 12] | [24, 12] | Passed |
| control 4 | [2969, 96] | [2969, 96] | Passed |
| boundary 5 | [16, 24] | [16, 24] | Passed |
| boundary 6 | [40, 2600] | [40, 2600] | Passed |
| control 7 | [8, 24] | [8, 24] | Passed |
SHA-256 / eab56c48cf4be139e0152dd067315f33bf1249b93ed72e9c3b3966106d636dc6
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
w, h, tag, sampling = x
mcu = {'444': (8, 8), '422': (16, 8), '420': (16, 16), '440': (8, 16)}
if sampling not in mcu:
return 'unknown-sampling'
mw, mh = mcu[sampling]
flips = {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)}
fx, fy, tr = flips.get(tag, (0, 0, 0))
tw = w - w % mw if fx else w
th = h - h % mh if fy else h
if tw == 0 or th == 0:
return 'refuse'
if tr:
tw, th = th, tw
return [tw, th]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[8, 8, 4, '440'], 'refuse'], [[16, 170, 8, '420'], [170, 16]], [[8, 8, 8, '440'], [8, 8]], [[24, 12, 0, '440'], [24, 12]], [[2969, 96, 1, '422'], [2969, 96]], [[24, 16, 5, '422'], [16, 24]], [[40, 2600, 0, '440'], [40, 2600]], [[24, 12, 6, '444'], [8, 24]]], [[[25, 8, 8, '420'], [8, 16]], [[2388, 13, 5, '420'], [13, 2388]], [[8, 12, 8, '440'], [12, 8]], [[8, 12, 1, '411'], 'unknown-sampling'], [[8, 2948, 7, '422'], 'refuse'], [[24, 24, 0, '422'], [24, 24]], [[16, 16, 6, '444'], [16, 16]], [[24, 24, 2, '440'], [24, 24]]], [[[8, 8, 6, '440'], 'refuse'], [[8, 12, 5, '422'], [12, 8]], [[24, 20, 8, '422'], [20, 16]], [[12, 12, 3, '420'], 'refuse'], [[24, 24, 0, '420'], [24, 24]], [[40, 24, 0, '422'], [40, 24]], [[865, 24, 5, '422'], [24, 865]], [[24, 12, 6, '422'], [8, 24]]], [[[24, 24, 4, '420'], [24, 16]], [[40, 58, 8, '422'], [58, 32]], [[40, 12, 8, '422'], [12, 32]], [[16, 272, 4, '422'], [16, 272]], [[24, 16, 6, '440'], [16, 24]], [[55, 16, 6, '440'], [16, 55]], [[24, 4, 3, '422'], 'refuse'], [[24, 12, 6, '420'], 'refuse']], [[[1545, 12, 6, '422'], [8, 1545]], [[12, 20, 8, '440'], [20, 8]], [[40, 20, 8, '440'], [20, 40]], [[8, 688, 2, '420'], 'refuse'], [[24, 8, 6, '422'], [8, 24]], [[8, 67, 7, '444'], [64, 8]], [[16, 24, 2, '411'], 'unknown-sampling'], [[8, 1190, 6, '444'], [1184, 8]]]]
labels = ["regression: height trim condition", "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: height trim condition 0 | refuse | refuse | Passed |
| repair trap 1 | [170, 16] | [170, 16] | Passed |
| combined fault 2 | [8, 8] | [8, 8] | Passed |
| control 3 | [24, 12] | [24, 12] | Passed |
| control 4 | [2969, 96] | [2969, 96] | Passed |
| boundary 5 | [16, 24] | [16, 24] | Passed |
| boundary 6 | [40, 2600] | [40, 2600] | Passed |
| control 7 | [8, 24] | [8, 24] | Passed |
SHA-256 / 32ac76e5d35700b957a4187bb9d847588fe838ecdf4cb6cfbd786d256096de3b
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:41.125407+00:00.
Case digest / 1c12808e1fcf20d0df19fb194e3f6cb028af9387fe0a0af13c6e89bd6d128128