{"abstract":"Clockwise-rotated photos keep a partial bottom MCU row that ends up as a garbage left column.","category":"Image orientation metadata","checks":8,"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\".","evaluation_group":"w2-image-orientation-metadata-lossless-mcu-trim","failed_approach":"Trimming for every transposing tag also trims transpose (5), which moves no partial block to a leading edge.","family":"w2-image-orientation-metadata-lossless-mcu-trim-vertical-flip-flag","id":"FA-79066","implementations":{"attempt":{"sha256":"eab56c48cf4be139e0152dd067315f33bf1249b93ed72e9c3b3966106d636dc6","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    w, h, tag, sampling = x\n    mcu = {'444': (8, 8), '422': (16, 8), '420': (16, 16), '440': (8, 16)}\n    if sampling not in mcu:\n        return 'unknown-sampling'\n    mw, mh = mcu[sampling]\n    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)}\n    fx, fy, tr = flips.get(tag, (0, 0, 0))\n    tw = w - w % mw if fx else w\n    th = h - h % mh if (fy or tr) else h\n    if tw == 0 or th == 0:\n        return 'refuse'\n    if tr:\n        tw, th = th, tw\n    return [tw, th]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[[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]]]]\nlabels = [\"regression: height trim condition\", \"repair trap\", \"combined fault\", \"control\", \"control\", \"boundary\", \"boundary\", \"control\"]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (labels[i % len(labels)], i), solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"f5c5b6f90805090973210c3959698af92ded30517a5ed439662526092265bb7c","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    w, h, tag, sampling = x\n    mcu = {'444': (8, 8), '422': (16, 8), '420': (16, 16), '440': (8, 16)}\n    if sampling not in mcu:\n        return 'unknown-sampling'\n    mw, mh = mcu[sampling]\n    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)}\n    fx, fy, tr = flips.get(tag, (0, 0, 0))\n    tw = w - w % mw if fx else w\n    th = h - h % mh if fx else h\n    if tw == 0 or th == 0:\n        return 'refuse'\n    if tr:\n        tw, th = th, tw\n    return [tw, th]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[[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]]]]\nlabels = [\"regression: height trim condition\", \"repair trap\", \"combined fault\", \"control\", \"control\", \"boundary\", \"boundary\", \"control\"]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (labels[i % len(labels)], i), solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"32ac76e5d35700b957a4187bb9d847588fe838ecdf4cb6cfbd786d256096de3b","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    w, h, tag, sampling = x\n    mcu = {'444': (8, 8), '422': (16, 8), '420': (16, 16), '440': (8, 16)}\n    if sampling not in mcu:\n        return 'unknown-sampling'\n    mw, mh = mcu[sampling]\n    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)}\n    fx, fy, tr = flips.get(tag, (0, 0, 0))\n    tw = w - w % mw if fx else w\n    th = h - h % mh if fy else h\n    if tw == 0 or th == 0:\n        return 'refuse'\n    if tr:\n        tw, th = th, tw\n    return [tw, th]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[[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]]]]\nlabels = [\"regression: height trim condition\", \"repair trap\", \"combined fault\", \"control\", \"control\", \"boundary\", \"boundary\", \"control\"]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (labels[i % len(labels)], i), solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-image-orientation-metadata-lossless-mcu-trim-vertical-flip-flag","generated_at":"2026-09-29T14:49:41.125407+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"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.","repair":"Trim the height exactly when the decomposition flips vertically in stored space.","root_cause":"The height trim is keyed on the horizontal flip flag.","sha256":"1c12808e1fcf20d0df19fb194e3f6cb028af9387fe0a0af13c6e89bd6d128128","title":"Height is trimmed for horizontal flips instead of vertical ones · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":38.093,"exit_code":1,"observations":[{"actual":"refuse","check":"regression: height trim condition 0","expected":"refuse","passed":true},{"actual":[160,16],"check":"repair trap 1","expected":[170,16],"passed":false},{"actual":"refuse","check":"combined fault 2","expected":[8,8],"passed":false},{"actual":[24,12],"check":"control 3","expected":[24,12],"passed":true},{"actual":[2969,96],"check":"control 4","expected":[2969,96],"passed":true},{"actual":[16,24],"check":"boundary 5","expected":[16,24],"passed":true},{"actual":[40,2600],"check":"boundary 6","expected":[40,2600],"passed":true},{"actual":[8,24],"check":"control 7","expected":[8,24],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: height trim condition 0\", \"actual\": \"refuse\", \"expected\": \"refuse\", \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": [160, 16], \"expected\": [170, 16], \"passed\": false}, {\"check\": \"combined fault 2\", \"actual\": \"refuse\", \"expected\": [8, 8], \"passed\": false}, {\"check\": \"control 3\", \"actual\": [24, 12], \"expected\": [24, 12], \"passed\": true}, {\"check\": \"control 4\", \"actual\": [2969, 96], \"expected\": [2969, 96], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": [16, 24], \"expected\": [16, 24], \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": [40, 2600], \"expected\": [40, 2600], \"passed\": true}, {\"check\": \"control 7\", \"actual\": [8, 24], \"expected\": [8, 24], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":36.444,"exit_code":1,"observations":[{"actual":[8,8],"check":"regression: height trim condition 0","expected":"refuse","passed":false},{"actual":[160,16],"check":"repair trap 1","expected":[170,16],"passed":false},{"actual":"refuse","check":"combined fault 2","expected":[8,8],"passed":false},{"actual":[24,12],"check":"control 3","expected":[24,12],"passed":true},{"actual":[2969,96],"check":"control 4","expected":[2969,96],"passed":true},{"actual":[16,24],"check":"boundary 5","expected":[16,24],"passed":true},{"actual":[40,2600],"check":"boundary 6","expected":[40,2600],"passed":true},{"actual":[12,24],"check":"control 7","expected":[8,24],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: height trim condition 0\", \"actual\": [8, 8], \"expected\": \"refuse\", \"passed\": false}, {\"check\": \"repair trap 1\", \"actual\": [160, 16], \"expected\": [170, 16], \"passed\": false}, {\"check\": \"combined fault 2\", \"actual\": \"refuse\", \"expected\": [8, 8], \"passed\": false}, {\"check\": \"control 3\", \"actual\": [24, 12], \"expected\": [24, 12], \"passed\": true}, {\"check\": \"control 4\", \"actual\": [2969, 96], \"expected\": [2969, 96], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": [16, 24], \"expected\": [16, 24], \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": [40, 2600], \"expected\": [40, 2600], \"passed\": true}, {\"check\": \"control 7\", \"actual\": [12, 24], \"expected\": [8, 24], \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":38.518,"exit_code":0,"observations":[{"actual":"refuse","check":"regression: height trim condition 0","expected":"refuse","passed":true},{"actual":[170,16],"check":"repair trap 1","expected":[170,16],"passed":true},{"actual":[8,8],"check":"combined fault 2","expected":[8,8],"passed":true},{"actual":[24,12],"check":"control 3","expected":[24,12],"passed":true},{"actual":[2969,96],"check":"control 4","expected":[2969,96],"passed":true},{"actual":[16,24],"check":"boundary 5","expected":[16,24],"passed":true},{"actual":[40,2600],"check":"boundary 6","expected":[40,2600],"passed":true},{"actual":[8,24],"check":"control 7","expected":[8,24],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: height trim condition 0\", \"actual\": \"refuse\", \"expected\": \"refuse\", \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": [170, 16], \"expected\": [170, 16], \"passed\": true}, {\"check\": \"combined fault 2\", \"actual\": [8, 8], \"expected\": [8, 8], \"passed\": true}, {\"check\": \"control 3\", \"actual\": [24, 12], \"expected\": [24, 12], \"passed\": true}, {\"check\": \"control 4\", \"actual\": [2969, 96], \"expected\": [2969, 96], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": [16, 24], \"expected\": [16, 24], \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": [40, 2600], \"expected\": [40, 2600], \"passed\": true}, {\"check\": \"control 7\", \"actual\": [8, 24], \"expected\": [8, 24], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}