FA-78986 / Image orientation metadata / Open access
Thumbnail width is truncated instead of rounded · case 01
Thumbnails are one pixel narrower than expected whenever the exact width has a fractional part of one half or more.
ROOT CAUSE
The scaled width is floored.
VERIFIED REPAIR
Round the exact scaled width half up.
Unsuccessful approach: Python round uses banker's rounding and rounds 2.5 down to 2.
Case contract
Input [stored_w, stored_h, tag, box_w, box_h]. Compute the displayed thumbnail size: tags 5..8 swap the displayed dimensions (other values, including invalid tags, do not). Scale = min(box_w/dw, box_h/dh, 1) exactly (never upscale); each side is rounded half up and is at least 1 pixel.
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(x):
w, h, tag, bw, bh = x
if tag in (5, 6, 7, 8):
w, h = h, w
s = min(Fraction(bw, w), Fraction(bh, h), Fraction(1))
tw = max(1, math.floor(w * s))
th = max(1, math.floor(h * s + Fraction(1, 2)))
return [tw, th]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[2477, 3237, 0, 10, 10], [8, 10]], [[5, 2, 1, 10, 1], [3, 1]], [[25, 2, 6, 76, 343], [2, 25]], [[3, 1, 6, 10, 10], [1, 3]], [[5, 2, 2, 10, 2], [5, 2]], [[15, 10, 8, 361, 38], [10, 15]], [[5, 4158, 8, 2, 2], [2, 1]], [[57, 33, 9, 10, 5], [9, 5]]], [[[25, 56, 7, 397, 12], [27, 12]], [[9, 2, 1, 20, 1], [5, 1]], [[5, 2, 1, 10, 1], [3, 1]], [[5, 2, 1, 19, 25], [5, 2]], [[25, 7, 2, 2, 145], [2, 1]], [[17, 50, 7, 72, 27], [50, 17]], [[15, 2, 0, 2, 2], [2, 1]], [[58, 7, 2, 168, 2], [17, 2]]], [[[5, 19, 6, 165, 2], [8, 2]], [[13, 6, 1, 40, 3], [7, 3]], [[5, 2, 1, 10, 1], [3, 1]], [[152, 2, 2, 2, 10], [2, 1]], [[12, 1369, 3, 1, 30], [1, 30]], [[15, 1, 1, 11, 291], [11, 1]], [[25, 7, 7, 10, 345], [7, 25]], [[35, 7, 6, 66, 19], [4, 19]]], [[[25, 7, 8, 10, 10], [3, 10]], [[5, 2, 1, 10, 1], [3, 1]], [[1283, 2, 6, 10, 2], [1, 2]], [[5, 2, 6, 18, 92], [2, 5]], [[5, 2, 8, 2, 10], [2, 5]], [[25, 1230, 1, 10, 10], [1, 10]], [[3, 5, 2, 2, 22], [2, 3]], [[15, 44, 8, 10, 2], [6, 2]]], [[[25, 1721, 9, 40, 380], [6, 380]], [[9, 2, 1, 20, 1], [5, 1]], [[5, 2, 1, 10, 1], [3, 1]], [[1251, 51, 3, 2, 2], [2, 1]], [[3903, 7, 9, 364, 10], [364, 1]], [[3907, 2, 8, 28, 202], [1, 202]], [[25, 2, 4, 54, 2], [25, 2]], [[5, 212, 3, 281, 108], [3, 108]]]]
labels = ["regression: width rounding", "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: width rounding 0 | [7, 10] | [8, 10] | Failed |
| repair trap 1 | [2, 1] | [3, 1] | Failed |
| combined fault 2 | [2, 25] | [2, 25] | Passed |
| control 3 | [1, 3] | [1, 3] | Passed |
| control 4 | [5, 2] | [5, 2] | Passed |
| boundary 5 | [10, 15] | [10, 15] | Passed |
| boundary 6 | [2, 1] | [2, 1] | Passed |
| control 7 | [8, 5] | [9, 5] | Failed |
SHA-256 / ae69a2f1f89c2aea0c907a9647a84652fc2d9d5adfa5c59f0f1ebb8d6156cd73
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(x):
w, h, tag, bw, bh = x
if tag in (5, 6, 7, 8):
w, h = h, w
s = min(Fraction(bw, w), Fraction(bh, h), Fraction(1))
tw = max(1, round(w * s))
th = max(1, math.floor(h * s + Fraction(1, 2)))
return [tw, th]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[2477, 3237, 0, 10, 10], [8, 10]], [[5, 2, 1, 10, 1], [3, 1]], [[25, 2, 6, 76, 343], [2, 25]], [[3, 1, 6, 10, 10], [1, 3]], [[5, 2, 2, 10, 2], [5, 2]], [[15, 10, 8, 361, 38], [10, 15]], [[5, 4158, 8, 2, 2], [2, 1]], [[57, 33, 9, 10, 5], [9, 5]]], [[[25, 56, 7, 397, 12], [27, 12]], [[9, 2, 1, 20, 1], [5, 1]], [[5, 2, 1, 10, 1], [3, 1]], [[5, 2, 1, 19, 25], [5, 2]], [[25, 7, 2, 2, 145], [2, 1]], [[17, 50, 7, 72, 27], [50, 17]], [[15, 2, 0, 2, 2], [2, 1]], [[58, 7, 2, 168, 2], [17, 2]]], [[[5, 19, 6, 165, 2], [8, 2]], [[13, 6, 1, 40, 3], [7, 3]], [[5, 2, 1, 10, 1], [3, 1]], [[152, 2, 2, 2, 10], [2, 1]], [[12, 1369, 3, 1, 30], [1, 30]], [[15, 1, 1, 11, 291], [11, 1]], [[25, 7, 7, 10, 345], [7, 25]], [[35, 7, 6, 66, 19], [4, 19]]], [[[25, 7, 8, 10, 10], [3, 10]], [[5, 2, 1, 10, 1], [3, 1]], [[1283, 2, 6, 10, 2], [1, 2]], [[5, 2, 6, 18, 92], [2, 5]], [[5, 2, 8, 2, 10], [2, 5]], [[25, 1230, 1, 10, 10], [1, 10]], [[3, 5, 2, 2, 22], [2, 3]], [[15, 44, 8, 10, 2], [6, 2]]], [[[25, 1721, 9, 40, 380], [6, 380]], [[9, 2, 1, 20, 1], [5, 1]], [[5, 2, 1, 10, 1], [3, 1]], [[1251, 51, 3, 2, 2], [2, 1]], [[3903, 7, 9, 364, 10], [364, 1]], [[3907, 2, 8, 28, 202], [1, 202]], [[25, 2, 4, 54, 2], [25, 2]], [[5, 212, 3, 281, 108], [3, 108]]]]
labels = ["regression: width rounding", "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: width rounding 0 | [8, 10] | [8, 10] | Passed |
| repair trap 1 | [2, 1] | [3, 1] | Failed |
| combined fault 2 | [2, 25] | [2, 25] | Passed |
| control 3 | [1, 3] | [1, 3] | Passed |
| control 4 | [5, 2] | [5, 2] | Passed |
| boundary 5 | [10, 15] | [10, 15] | Passed |
| boundary 6 | [2, 1] | [2, 1] | Passed |
| control 7 | [9, 5] | [9, 5] | Passed |
SHA-256 / 1f82d021164d695ca163d7807717b0089465820d2537154c615b772089b93c93
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(x):
w, h, tag, bw, bh = x
if tag in (5, 6, 7, 8):
w, h = h, w
s = min(Fraction(bw, w), Fraction(bh, h), Fraction(1))
tw = max(1, math.floor(w * s + Fraction(1, 2)))
th = max(1, math.floor(h * s + Fraction(1, 2)))
return [tw, th]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[2477, 3237, 0, 10, 10], [8, 10]], [[5, 2, 1, 10, 1], [3, 1]], [[25, 2, 6, 76, 343], [2, 25]], [[3, 1, 6, 10, 10], [1, 3]], [[5, 2, 2, 10, 2], [5, 2]], [[15, 10, 8, 361, 38], [10, 15]], [[5, 4158, 8, 2, 2], [2, 1]], [[57, 33, 9, 10, 5], [9, 5]]], [[[25, 56, 7, 397, 12], [27, 12]], [[9, 2, 1, 20, 1], [5, 1]], [[5, 2, 1, 10, 1], [3, 1]], [[5, 2, 1, 19, 25], [5, 2]], [[25, 7, 2, 2, 145], [2, 1]], [[17, 50, 7, 72, 27], [50, 17]], [[15, 2, 0, 2, 2], [2, 1]], [[58, 7, 2, 168, 2], [17, 2]]], [[[5, 19, 6, 165, 2], [8, 2]], [[13, 6, 1, 40, 3], [7, 3]], [[5, 2, 1, 10, 1], [3, 1]], [[152, 2, 2, 2, 10], [2, 1]], [[12, 1369, 3, 1, 30], [1, 30]], [[15, 1, 1, 11, 291], [11, 1]], [[25, 7, 7, 10, 345], [7, 25]], [[35, 7, 6, 66, 19], [4, 19]]], [[[25, 7, 8, 10, 10], [3, 10]], [[5, 2, 1, 10, 1], [3, 1]], [[1283, 2, 6, 10, 2], [1, 2]], [[5, 2, 6, 18, 92], [2, 5]], [[5, 2, 8, 2, 10], [2, 5]], [[25, 1230, 1, 10, 10], [1, 10]], [[3, 5, 2, 2, 22], [2, 3]], [[15, 44, 8, 10, 2], [6, 2]]], [[[25, 1721, 9, 40, 380], [6, 380]], [[9, 2, 1, 20, 1], [5, 1]], [[5, 2, 1, 10, 1], [3, 1]], [[1251, 51, 3, 2, 2], [2, 1]], [[3903, 7, 9, 364, 10], [364, 1]], [[3907, 2, 8, 28, 202], [1, 202]], [[25, 2, 4, 54, 2], [25, 2]], [[5, 212, 3, 281, 108], [3, 108]]]]
labels = ["regression: width rounding", "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: width rounding 0 | [8, 10] | [8, 10] | Passed |
| repair trap 1 | [3, 1] | [3, 1] | Passed |
| combined fault 2 | [2, 25] | [2, 25] | Passed |
| control 3 | [1, 3] | [1, 3] | Passed |
| control 4 | [5, 2] | [5, 2] | Passed |
| boundary 5 | [10, 15] | [10, 15] | Passed |
| boundary 6 | [2, 1] | [2, 1] | Passed |
| control 7 | [9, 5] | [9, 5] | Passed |
SHA-256 / 51c0e186f301730cd329f7e8643b132fefebb5769dcffd71e5ec259c76a0742b
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:40.484964+00:00.
Case digest / 0b0a8faf1528e62ebbdc9ec8677d4930989431625a7ee0d6d8509c815cff465d