FA-79211 / Image orientation metadata / Open access
Missing ResolutionUnit is treated as unitless · case 01
Most camera JPEGs, which omit the unit, report no physical print size.
ROOT CAUSE
An absent unit defaults to 1 (no absolute unit) instead of the inch default.
VERIFIED REPAIR
Default the unit to 2 (inches) when the tag is absent.
Unsuccessful approach: Defaulting to centimetres makes prints 2.54 times too large.
Case contract
Input {w, h, tag?, unit?, xres: [num, den], yres?: [num, den]}. ResolutionUnit 2 is inches (25.4 mm), 3 is centimetres (10 mm), a missing unit defaults to 2 and any other unit has no physical size (None). A missing yres equals xres; non-positive rational parts give None. For tags 5..8 the displayed width comes from the stored height at YResolution. Return displayed [width, height] in tenths of a millimetre, each rounded half up from the exact value.
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(d):
w, h = d['w'], d['h']
tag = d.get('tag', 1)
unit = d.get('unit', 1)
per = {2: Fraction(254, 10), 3: Fraction(10)}.get(unit)
if per is None:
return None
xn, xd = d['xres']
yn, yd = d.get('yres', d['xres'])
if xn <= 0 or xd <= 0 or yn <= 0 or yd <= 0:
return None
xr = Fraction(xn, xd)
yr = Fraction(yn, yd)
if tag in (5, 6, 7, 8):
w, h, xr, yr = h, w, yr, xr
def tenths(px, r):
return math.floor(px * per * 10 / r + Fraction(1, 2))
return [tenths(w, xr), tenths(h, yr)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[{'w': 2250, 'h': 3721, 'tag': 6, 'xres': [300, 1]}, [3150, 1905]], [{'w': 2868, 'h': 1537, 'tag': 6, 'xres': [40, 1], 'yres': [1000, 3]}, [1171, 18212]], [{'w': 2577, 'h': 2775, 'tag': 6, 'xres': [0, 1]}, None], [{'w': 3942, 'h': 988, 'tag': 8, 'unit': 3, 'xres': [72, 1]}, [1372, 5475]], [{'w': 2676, 'h': 1814, 'tag': 6, 'unit': 3, 'xres': [300, 1], 'yres': [600, 1]}, [302, 892]], [{'w': 2042, 'h': 678, 'unit': 3, 'xres': [150, 2]}, [2723, 904]], [{'w': 456, 'h': 408, 'tag': 8, 'unit': 3, 'xres': [96, 1], 'yres': [96, 1]}, [425, 475]], [{'w': 3491, 'h': 649, 'xres': [40, 1], 'yres': [1000, 3]}, [22168, 495]]], [[{'w': 3380, 'h': 2534, 'tag': 6, 'xres': [300, 1]}, [2145, 2862]], [{'w': 355, 'h': 1835, 'xres': [200, 3], 'yres': [72, 1]}, [1353, 6473]], [{'w': 553, 'h': 1044, 'tag': 8, 'unit': 2, 'xres': [200, 3], 'yres': [-300, 1]}, None], [{'w': 2636, 'h': 3063, 'unit': 3, 'xres': [200, 3], 'yres': [300, 1]}, [3954, 1021]], [{'w': 1140, 'h': 2204, 'tag': 5, 'unit': 3, 'xres': [40, 1], 'yres': [96, 1]}, [2296, 2850]], [{'w': 3188, 'h': 3159, 'tag': 1, 'unit': 2, 'xres': [1000, 3]}, [2429, 2407]], [{'w': 3266, 'h': 1419, 'tag': 5, 'unit': 3, 'xres': [300, 1], 'yres': [1000, 3]}, [426, 1089]], [{'w': 1272, 'h': 2208, 'tag': 8, 'xres': [72, 1], 'yres': [600, 1]}, [935, 4487]]], [[{'w': 2032, 'h': 1531, 'tag': 8, 'xres': [72, 1], 'yres': [300, 1]}, [1296, 7168]], [{'w': 3347, 'h': 34, 'tag': 5, 'xres': [72, 1], 'yres': [96, 1]}, [90, 11807]], [{'w': 2, 'h': 3716, 'unit': 2, 'xres': [300, 1]}, [2, 3146]], [{'w': 724, 'h': 1179, 'unit': 2, 'xres': [40, 1], 'yres': [-300, 1]}, None], [{'w': 3823, 'h': 2286, 'tag': 8, 'unit': 3, 'xres': [150, 2], 'yres': [1000, 3]}, [686, 5097]], [{'w': 2151, 'h': 2111, 'tag': 5, 'unit': 2, 'xres': [7200, 100]}, [7447, 7588]], [{'w': 3954, 'h': 1399, 'tag': 8, 'unit': 3, 'xres': [72, 1]}, [1943, 5492]], [{'w': 3374, 'h': 1982, 'tag': 3, 'xres': [300, 1], 'yres': [1000, 3]}, [2857, 1510]]], [[{'w': 233, 'h': 3163, 'tag': 2, 'xres': [150, 2], 'yres': [72, 1]}, [789, 11158]], [{'w': 2175, 'h': 653, 'tag': 2, 'xres': [300, 1]}, [1842, 553]], [{'w': 1, 'h': 3356, 'tag': 7, 'xres': [-72, 1], 'yres': [96, 1]}, None], [{'w': 776, 'h': 1736, 'tag': 1, 'unit': 3, 'xres': [96, 1]}, [808, 1808]], [{'w': 3732, 'h': 1632, 'tag': 6, 'unit': 3, 'xres': [150, 2], 'yres': [72, 1]}, [2267, 4976]], [{'w': 2768, 'h': 3254, 'tag': 1, 'unit': 3, 'xres': [300, 1]}, [923, 1085]], [{'w': 1975, 'h': 3847, 'tag': 8, 'unit': 2, 'xres': [72, 1], 'yres': [40, 1]}, [24428, 6967]], [{'w': 177, 'h': 2683, 'xres': [72, 1], 'yres': [1000, 3]}, [624, 2044]]], [[{'w': 3766, 'h': 3194, 'tag': 8, 'xres': [150, 2], 'yres': [300, 1]}, [2704, 12754]], [{'w': 1412, 'h': 1258, 'xres': [150, 2]}, [4782, 4260]], [{'w': 3908, 'h': 2121, 'tag': 6, 'unit': 1, 'xres': [96, 1], 'yres': [40, 1]}, None], [{'w': 2271, 'h': 2906, 'tag': 1, 'unit': 3, 'xres': [72, 1]}, [3154, 4036]], [{'w': 3285, 'h': 917, 'tag': 3, 'unit': 3, 'xres': [300, 1], 'yres': [72, 1]}, [1095, 1274]], [{'w': 2070, 'h': 2469, 'tag': 1, 'unit': 3, 'xres': [0, 1], 'yres': [-300, 1]}, None], [{'w': 901, 'h': 2455, 'tag': 6, 'unit': 3, 'xres': [7200, 100], 'yres': [600, 1]}, [409, 1251]], [{'w': 3018, 'h': 798, 'tag': 8, 'xres': [7200, 100], 'yres': [600, 1]}, [338, 10647]]]]
labels = ["regression: default resolution unit", "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: default resolution unit 0 | None | [3150, 1905] | Failed |
| repair trap 1 | None | [1171, 18212] | Failed |
| combined fault 2 | None | None | Passed |
| control 3 | [1372, 5475] | [1372, 5475] | Passed |
| control 4 | [302, 892] | [302, 892] | Passed |
| boundary 5 | [2723, 904] | [2723, 904] | Passed |
| boundary 6 | [425, 475] | [425, 475] | Passed |
| control 7 | None | [22168, 495] | Failed |
SHA-256 / 3e2f8f7b7b229381d94bd84d97713bcfc224dfcec0c7c0f8b8c3fc09b33f9b88
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(d):
w, h = d['w'], d['h']
tag = d.get('tag', 1)
unit = d.get('unit') or 3
per = {2: Fraction(254, 10), 3: Fraction(10)}.get(unit)
if per is None:
return None
xn, xd = d['xres']
yn, yd = d.get('yres', d['xres'])
if xn <= 0 or xd <= 0 or yn <= 0 or yd <= 0:
return None
xr = Fraction(xn, xd)
yr = Fraction(yn, yd)
if tag in (5, 6, 7, 8):
w, h, xr, yr = h, w, yr, xr
def tenths(px, r):
return math.floor(px * per * 10 / r + Fraction(1, 2))
return [tenths(w, xr), tenths(h, yr)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[{'w': 2250, 'h': 3721, 'tag': 6, 'xres': [300, 1]}, [3150, 1905]], [{'w': 2868, 'h': 1537, 'tag': 6, 'xres': [40, 1], 'yres': [1000, 3]}, [1171, 18212]], [{'w': 2577, 'h': 2775, 'tag': 6, 'xres': [0, 1]}, None], [{'w': 3942, 'h': 988, 'tag': 8, 'unit': 3, 'xres': [72, 1]}, [1372, 5475]], [{'w': 2676, 'h': 1814, 'tag': 6, 'unit': 3, 'xres': [300, 1], 'yres': [600, 1]}, [302, 892]], [{'w': 2042, 'h': 678, 'unit': 3, 'xres': [150, 2]}, [2723, 904]], [{'w': 456, 'h': 408, 'tag': 8, 'unit': 3, 'xres': [96, 1], 'yres': [96, 1]}, [425, 475]], [{'w': 3491, 'h': 649, 'xres': [40, 1], 'yres': [1000, 3]}, [22168, 495]]], [[{'w': 3380, 'h': 2534, 'tag': 6, 'xres': [300, 1]}, [2145, 2862]], [{'w': 355, 'h': 1835, 'xres': [200, 3], 'yres': [72, 1]}, [1353, 6473]], [{'w': 553, 'h': 1044, 'tag': 8, 'unit': 2, 'xres': [200, 3], 'yres': [-300, 1]}, None], [{'w': 2636, 'h': 3063, 'unit': 3, 'xres': [200, 3], 'yres': [300, 1]}, [3954, 1021]], [{'w': 1140, 'h': 2204, 'tag': 5, 'unit': 3, 'xres': [40, 1], 'yres': [96, 1]}, [2296, 2850]], [{'w': 3188, 'h': 3159, 'tag': 1, 'unit': 2, 'xres': [1000, 3]}, [2429, 2407]], [{'w': 3266, 'h': 1419, 'tag': 5, 'unit': 3, 'xres': [300, 1], 'yres': [1000, 3]}, [426, 1089]], [{'w': 1272, 'h': 2208, 'tag': 8, 'xres': [72, 1], 'yres': [600, 1]}, [935, 4487]]], [[{'w': 2032, 'h': 1531, 'tag': 8, 'xres': [72, 1], 'yres': [300, 1]}, [1296, 7168]], [{'w': 3347, 'h': 34, 'tag': 5, 'xres': [72, 1], 'yres': [96, 1]}, [90, 11807]], [{'w': 2, 'h': 3716, 'unit': 2, 'xres': [300, 1]}, [2, 3146]], [{'w': 724, 'h': 1179, 'unit': 2, 'xres': [40, 1], 'yres': [-300, 1]}, None], [{'w': 3823, 'h': 2286, 'tag': 8, 'unit': 3, 'xres': [150, 2], 'yres': [1000, 3]}, [686, 5097]], [{'w': 2151, 'h': 2111, 'tag': 5, 'unit': 2, 'xres': [7200, 100]}, [7447, 7588]], [{'w': 3954, 'h': 1399, 'tag': 8, 'unit': 3, 'xres': [72, 1]}, [1943, 5492]], [{'w': 3374, 'h': 1982, 'tag': 3, 'xres': [300, 1], 'yres': [1000, 3]}, [2857, 1510]]], [[{'w': 233, 'h': 3163, 'tag': 2, 'xres': [150, 2], 'yres': [72, 1]}, [789, 11158]], [{'w': 2175, 'h': 653, 'tag': 2, 'xres': [300, 1]}, [1842, 553]], [{'w': 1, 'h': 3356, 'tag': 7, 'xres': [-72, 1], 'yres': [96, 1]}, None], [{'w': 776, 'h': 1736, 'tag': 1, 'unit': 3, 'xres': [96, 1]}, [808, 1808]], [{'w': 3732, 'h': 1632, 'tag': 6, 'unit': 3, 'xres': [150, 2], 'yres': [72, 1]}, [2267, 4976]], [{'w': 2768, 'h': 3254, 'tag': 1, 'unit': 3, 'xres': [300, 1]}, [923, 1085]], [{'w': 1975, 'h': 3847, 'tag': 8, 'unit': 2, 'xres': [72, 1], 'yres': [40, 1]}, [24428, 6967]], [{'w': 177, 'h': 2683, 'xres': [72, 1], 'yres': [1000, 3]}, [624, 2044]]], [[{'w': 3766, 'h': 3194, 'tag': 8, 'xres': [150, 2], 'yres': [300, 1]}, [2704, 12754]], [{'w': 1412, 'h': 1258, 'xres': [150, 2]}, [4782, 4260]], [{'w': 3908, 'h': 2121, 'tag': 6, 'unit': 1, 'xres': [96, 1], 'yres': [40, 1]}, None], [{'w': 2271, 'h': 2906, 'tag': 1, 'unit': 3, 'xres': [72, 1]}, [3154, 4036]], [{'w': 3285, 'h': 917, 'tag': 3, 'unit': 3, 'xres': [300, 1], 'yres': [72, 1]}, [1095, 1274]], [{'w': 2070, 'h': 2469, 'tag': 1, 'unit': 3, 'xres': [0, 1], 'yres': [-300, 1]}, None], [{'w': 901, 'h': 2455, 'tag': 6, 'unit': 3, 'xres': [7200, 100], 'yres': [600, 1]}, [409, 1251]], [{'w': 3018, 'h': 798, 'tag': 8, 'xres': [7200, 100], 'yres': [600, 1]}, [338, 10647]]]]
labels = ["regression: default resolution unit", "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: default resolution unit 0 | [1240, 750] | [3150, 1905] | Failed |
| repair trap 1 | [461, 7170] | [1171, 18212] | Failed |
| combined fault 2 | None | None | Passed |
| control 3 | [1372, 5475] | [1372, 5475] | Passed |
| control 4 | [302, 892] | [302, 892] | Passed |
| boundary 5 | [2723, 904] | [2723, 904] | Passed |
| boundary 6 | [425, 475] | [425, 475] | Passed |
| control 7 | [8728, 195] | [22168, 495] | Failed |
SHA-256 / 56348851618840add037812addbdbcde38f4ca38a73a7b18e0f4a06674a98e07
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(d):
w, h = d['w'], d['h']
tag = d.get('tag', 1)
unit = d.get('unit', 2)
per = {2: Fraction(254, 10), 3: Fraction(10)}.get(unit)
if per is None:
return None
xn, xd = d['xres']
yn, yd = d.get('yres', d['xres'])
if xn <= 0 or xd <= 0 or yn <= 0 or yd <= 0:
return None
xr = Fraction(xn, xd)
yr = Fraction(yn, yd)
if tag in (5, 6, 7, 8):
w, h, xr, yr = h, w, yr, xr
def tenths(px, r):
return math.floor(px * per * 10 / r + Fraction(1, 2))
return [tenths(w, xr), tenths(h, yr)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[{'w': 2250, 'h': 3721, 'tag': 6, 'xres': [300, 1]}, [3150, 1905]], [{'w': 2868, 'h': 1537, 'tag': 6, 'xres': [40, 1], 'yres': [1000, 3]}, [1171, 18212]], [{'w': 2577, 'h': 2775, 'tag': 6, 'xres': [0, 1]}, None], [{'w': 3942, 'h': 988, 'tag': 8, 'unit': 3, 'xres': [72, 1]}, [1372, 5475]], [{'w': 2676, 'h': 1814, 'tag': 6, 'unit': 3, 'xres': [300, 1], 'yres': [600, 1]}, [302, 892]], [{'w': 2042, 'h': 678, 'unit': 3, 'xres': [150, 2]}, [2723, 904]], [{'w': 456, 'h': 408, 'tag': 8, 'unit': 3, 'xres': [96, 1], 'yres': [96, 1]}, [425, 475]], [{'w': 3491, 'h': 649, 'xres': [40, 1], 'yres': [1000, 3]}, [22168, 495]]], [[{'w': 3380, 'h': 2534, 'tag': 6, 'xres': [300, 1]}, [2145, 2862]], [{'w': 355, 'h': 1835, 'xres': [200, 3], 'yres': [72, 1]}, [1353, 6473]], [{'w': 553, 'h': 1044, 'tag': 8, 'unit': 2, 'xres': [200, 3], 'yres': [-300, 1]}, None], [{'w': 2636, 'h': 3063, 'unit': 3, 'xres': [200, 3], 'yres': [300, 1]}, [3954, 1021]], [{'w': 1140, 'h': 2204, 'tag': 5, 'unit': 3, 'xres': [40, 1], 'yres': [96, 1]}, [2296, 2850]], [{'w': 3188, 'h': 3159, 'tag': 1, 'unit': 2, 'xres': [1000, 3]}, [2429, 2407]], [{'w': 3266, 'h': 1419, 'tag': 5, 'unit': 3, 'xres': [300, 1], 'yres': [1000, 3]}, [426, 1089]], [{'w': 1272, 'h': 2208, 'tag': 8, 'xres': [72, 1], 'yres': [600, 1]}, [935, 4487]]], [[{'w': 2032, 'h': 1531, 'tag': 8, 'xres': [72, 1], 'yres': [300, 1]}, [1296, 7168]], [{'w': 3347, 'h': 34, 'tag': 5, 'xres': [72, 1], 'yres': [96, 1]}, [90, 11807]], [{'w': 2, 'h': 3716, 'unit': 2, 'xres': [300, 1]}, [2, 3146]], [{'w': 724, 'h': 1179, 'unit': 2, 'xres': [40, 1], 'yres': [-300, 1]}, None], [{'w': 3823, 'h': 2286, 'tag': 8, 'unit': 3, 'xres': [150, 2], 'yres': [1000, 3]}, [686, 5097]], [{'w': 2151, 'h': 2111, 'tag': 5, 'unit': 2, 'xres': [7200, 100]}, [7447, 7588]], [{'w': 3954, 'h': 1399, 'tag': 8, 'unit': 3, 'xres': [72, 1]}, [1943, 5492]], [{'w': 3374, 'h': 1982, 'tag': 3, 'xres': [300, 1], 'yres': [1000, 3]}, [2857, 1510]]], [[{'w': 233, 'h': 3163, 'tag': 2, 'xres': [150, 2], 'yres': [72, 1]}, [789, 11158]], [{'w': 2175, 'h': 653, 'tag': 2, 'xres': [300, 1]}, [1842, 553]], [{'w': 1, 'h': 3356, 'tag': 7, 'xres': [-72, 1], 'yres': [96, 1]}, None], [{'w': 776, 'h': 1736, 'tag': 1, 'unit': 3, 'xres': [96, 1]}, [808, 1808]], [{'w': 3732, 'h': 1632, 'tag': 6, 'unit': 3, 'xres': [150, 2], 'yres': [72, 1]}, [2267, 4976]], [{'w': 2768, 'h': 3254, 'tag': 1, 'unit': 3, 'xres': [300, 1]}, [923, 1085]], [{'w': 1975, 'h': 3847, 'tag': 8, 'unit': 2, 'xres': [72, 1], 'yres': [40, 1]}, [24428, 6967]], [{'w': 177, 'h': 2683, 'xres': [72, 1], 'yres': [1000, 3]}, [624, 2044]]], [[{'w': 3766, 'h': 3194, 'tag': 8, 'xres': [150, 2], 'yres': [300, 1]}, [2704, 12754]], [{'w': 1412, 'h': 1258, 'xres': [150, 2]}, [4782, 4260]], [{'w': 3908, 'h': 2121, 'tag': 6, 'unit': 1, 'xres': [96, 1], 'yres': [40, 1]}, None], [{'w': 2271, 'h': 2906, 'tag': 1, 'unit': 3, 'xres': [72, 1]}, [3154, 4036]], [{'w': 3285, 'h': 917, 'tag': 3, 'unit': 3, 'xres': [300, 1], 'yres': [72, 1]}, [1095, 1274]], [{'w': 2070, 'h': 2469, 'tag': 1, 'unit': 3, 'xres': [0, 1], 'yres': [-300, 1]}, None], [{'w': 901, 'h': 2455, 'tag': 6, 'unit': 3, 'xres': [7200, 100], 'yres': [600, 1]}, [409, 1251]], [{'w': 3018, 'h': 798, 'tag': 8, 'xres': [7200, 100], 'yres': [600, 1]}, [338, 10647]]]]
labels = ["regression: default resolution unit", "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: default resolution unit 0 | [3150, 1905] | [3150, 1905] | Passed |
| repair trap 1 | [1171, 18212] | [1171, 18212] | Passed |
| combined fault 2 | None | None | Passed |
| control 3 | [1372, 5475] | [1372, 5475] | Passed |
| control 4 | [302, 892] | [302, 892] | Passed |
| boundary 5 | [2723, 904] | [2723, 904] | Passed |
| boundary 6 | [425, 475] | [425, 475] | Passed |
| control 7 | [22168, 495] | [22168, 495] | Passed |
SHA-256 / 5b1207309bcec094b3a8e33bee61405905e84766ed5ccd3fcec47e223459a99b
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:42.462552+00:00.
Case digest / 75c200a1986ca45b3e23f89ac52fdd35beea44bcd8cd9f5361225a7eb1eb63d3