FA-79226 / Image orientation metadata / Open access
Negative resolutions produce negative print sizes · case 01
A corrupt negative resolution yields a negative physical width in the print dialog.
ROOT CAUSE
Only zero denominators are rejected.
VERIFIED REPAIR
Reject any non-positive numerator or denominator.
Unsuccessful approach: Rejecting zeros still lets negative values through.
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', 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 xd == 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': 3975, 'h': 1299, 'unit': 2, 'xres': [300, 1], 'yres': [-300, 1]}, None], [{'w': 3587, 'h': 3996, 'tag': 1, 'unit': 2, 'xres': [-72, 1], 'yres': [72, 1]}, None], [{'w': 2250, 'h': 3721, 'tag': 6, 'xres': [300, 1]}, [3150, 1905]], [{'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': 3491, 'h': 649, 'xres': [40, 1], 'yres': [1000, 3]}, [22168, 495]], [{'w': 3914, 'h': 2626, 'tag': 6, 'unit': 3, 'xres': [96, 1], 'yres': [-300, 1]}, None]], [[{'w': 553, 'h': 1044, 'tag': 8, 'unit': 2, 'xres': [200, 3], 'yres': [-300, 1]}, None], [{'w': 1205, 'h': 2058, 'unit': 3, 'xres': [-72, 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': 3380, 'h': 2534, 'tag': 6, 'xres': [300, 1]}, [2145, 2862]], [{'w': 2562, 'h': 960, 'tag': 3, 'unit': 3, 'xres': [-72, 1], 'yres': [40, 1]}, None]], [[{'w': 3633, 'h': 2881, 'xres': [-72, 1]}, None], [{'w': 920, 'h': 3976, 'tag': 8, 'unit': 3, 'xres': [7200, 100], 'yres': [-300, 1]}, None], [{'w': 2, 'h': 3716, 'unit': 2, 'xres': [300, 1]}, [2, 3146]], [{'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': 724, 'h': 1179, 'unit': 2, 'xres': [40, 1], 'yres': [-300, 1]}, None]], [[{'w': 3153, 'h': 1191, 'tag': 3, 'unit': 3, 'xres': [300, 1], 'yres': [-300, 1]}, None], [{'w': 3562, 'h': 2092, 'unit': 2, 'xres': [-72, 1], 'yres': [96, 1]}, None], [{'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': 3043, 'h': 1338, 'tag': 8, 'unit': 1, 'xres': [200, 3], 'yres': [72, 1]}, None], [{'w': 1489, 'h': 2076, 'tag': 1, 'unit': 2, 'xres': [7200, 100], 'yres': [600, 1]}, [5253, 879]], [{'w': 1, 'h': 3356, 'tag': 7, 'xres': [-72, 1], 'yres': [96, 1]}, None]], [[{'w': 330, 'h': 2393, 'tag': 8, 'unit': 2, 'xres': [-72, 1], 'yres': [-300, 1]}, None], [{'w': 3687, 'h': 735, 'tag': 8, 'unit': 3, 'xres': [-72, 1], 'yres': [1000, 3]}, None], [{'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': 690, 'h': 269, 'xres': [40, 1], 'yres': [72, 1]}, [4382, 949]], [{'w': 2499, 'h': 800, 'tag': 6, 'xres': [150, 2]}, [2709, 8463]], [{'w': 2753, 'h': 567, 'tag': 1, 'unit': 2, 'xres': [150, 2], 'yres': [-300, 1]}, None]]]
labels = ["regression: rational sign validation", "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: rational sign validation 0 | [3366, -1100] | None | Failed |
| repair trap 1 | [-12654, 14097] | None | Failed |
| combined fault 2 | [3150, 1905] | [3150, 1905] | Passed |
| control 3 | [1372, 5475] | [1372, 5475] | Passed |
| control 4 | [302, 892] | [302, 892] | Passed |
| boundary 5 | [2723, 904] | [2723, 904] | Passed |
| boundary 6 | [22168, 495] | [22168, 495] | Passed |
| control 7 | [-875, 4077] | None | Failed |
SHA-256 / 204ab10b860d7d52aadb6bb09d3ab8a608e5be0e8e5a9584d0d4bfc85480d4b7
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', 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': 3975, 'h': 1299, 'unit': 2, 'xres': [300, 1], 'yres': [-300, 1]}, None], [{'w': 3587, 'h': 3996, 'tag': 1, 'unit': 2, 'xres': [-72, 1], 'yres': [72, 1]}, None], [{'w': 2250, 'h': 3721, 'tag': 6, 'xres': [300, 1]}, [3150, 1905]], [{'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': 3491, 'h': 649, 'xres': [40, 1], 'yres': [1000, 3]}, [22168, 495]], [{'w': 3914, 'h': 2626, 'tag': 6, 'unit': 3, 'xres': [96, 1], 'yres': [-300, 1]}, None]], [[{'w': 553, 'h': 1044, 'tag': 8, 'unit': 2, 'xres': [200, 3], 'yres': [-300, 1]}, None], [{'w': 1205, 'h': 2058, 'unit': 3, 'xres': [-72, 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': 3380, 'h': 2534, 'tag': 6, 'xres': [300, 1]}, [2145, 2862]], [{'w': 2562, 'h': 960, 'tag': 3, 'unit': 3, 'xres': [-72, 1], 'yres': [40, 1]}, None]], [[{'w': 3633, 'h': 2881, 'xres': [-72, 1]}, None], [{'w': 920, 'h': 3976, 'tag': 8, 'unit': 3, 'xres': [7200, 100], 'yres': [-300, 1]}, None], [{'w': 2, 'h': 3716, 'unit': 2, 'xres': [300, 1]}, [2, 3146]], [{'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': 724, 'h': 1179, 'unit': 2, 'xres': [40, 1], 'yres': [-300, 1]}, None]], [[{'w': 3153, 'h': 1191, 'tag': 3, 'unit': 3, 'xres': [300, 1], 'yres': [-300, 1]}, None], [{'w': 3562, 'h': 2092, 'unit': 2, 'xres': [-72, 1], 'yres': [96, 1]}, None], [{'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': 3043, 'h': 1338, 'tag': 8, 'unit': 1, 'xres': [200, 3], 'yres': [72, 1]}, None], [{'w': 1489, 'h': 2076, 'tag': 1, 'unit': 2, 'xres': [7200, 100], 'yres': [600, 1]}, [5253, 879]], [{'w': 1, 'h': 3356, 'tag': 7, 'xres': [-72, 1], 'yres': [96, 1]}, None]], [[{'w': 330, 'h': 2393, 'tag': 8, 'unit': 2, 'xres': [-72, 1], 'yres': [-300, 1]}, None], [{'w': 3687, 'h': 735, 'tag': 8, 'unit': 3, 'xres': [-72, 1], 'yres': [1000, 3]}, None], [{'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': 690, 'h': 269, 'xres': [40, 1], 'yres': [72, 1]}, [4382, 949]], [{'w': 2499, 'h': 800, 'tag': 6, 'xres': [150, 2]}, [2709, 8463]], [{'w': 2753, 'h': 567, 'tag': 1, 'unit': 2, 'xres': [150, 2], 'yres': [-300, 1]}, None]]]
labels = ["regression: rational sign validation", "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: rational sign validation 0 | [3366, -1100] | None | Failed |
| repair trap 1 | [-12654, 14097] | None | Failed |
| combined fault 2 | [3150, 1905] | [3150, 1905] | Passed |
| control 3 | [1372, 5475] | [1372, 5475] | Passed |
| control 4 | [302, 892] | [302, 892] | Passed |
| boundary 5 | [2723, 904] | [2723, 904] | Passed |
| boundary 6 | [22168, 495] | [22168, 495] | Passed |
| control 7 | [-875, 4077] | None | Failed |
SHA-256 / 1641e57ca4525b129654df94771e7a7e30dfdfadfaf55e2bb5a7e967e81bf5dc
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': 3975, 'h': 1299, 'unit': 2, 'xres': [300, 1], 'yres': [-300, 1]}, None], [{'w': 3587, 'h': 3996, 'tag': 1, 'unit': 2, 'xres': [-72, 1], 'yres': [72, 1]}, None], [{'w': 2250, 'h': 3721, 'tag': 6, 'xres': [300, 1]}, [3150, 1905]], [{'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': 3491, 'h': 649, 'xres': [40, 1], 'yres': [1000, 3]}, [22168, 495]], [{'w': 3914, 'h': 2626, 'tag': 6, 'unit': 3, 'xres': [96, 1], 'yres': [-300, 1]}, None]], [[{'w': 553, 'h': 1044, 'tag': 8, 'unit': 2, 'xres': [200, 3], 'yres': [-300, 1]}, None], [{'w': 1205, 'h': 2058, 'unit': 3, 'xres': [-72, 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': 3380, 'h': 2534, 'tag': 6, 'xres': [300, 1]}, [2145, 2862]], [{'w': 2562, 'h': 960, 'tag': 3, 'unit': 3, 'xres': [-72, 1], 'yres': [40, 1]}, None]], [[{'w': 3633, 'h': 2881, 'xres': [-72, 1]}, None], [{'w': 920, 'h': 3976, 'tag': 8, 'unit': 3, 'xres': [7200, 100], 'yres': [-300, 1]}, None], [{'w': 2, 'h': 3716, 'unit': 2, 'xres': [300, 1]}, [2, 3146]], [{'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': 724, 'h': 1179, 'unit': 2, 'xres': [40, 1], 'yres': [-300, 1]}, None]], [[{'w': 3153, 'h': 1191, 'tag': 3, 'unit': 3, 'xres': [300, 1], 'yres': [-300, 1]}, None], [{'w': 3562, 'h': 2092, 'unit': 2, 'xres': [-72, 1], 'yres': [96, 1]}, None], [{'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': 3043, 'h': 1338, 'tag': 8, 'unit': 1, 'xres': [200, 3], 'yres': [72, 1]}, None], [{'w': 1489, 'h': 2076, 'tag': 1, 'unit': 2, 'xres': [7200, 100], 'yres': [600, 1]}, [5253, 879]], [{'w': 1, 'h': 3356, 'tag': 7, 'xres': [-72, 1], 'yres': [96, 1]}, None]], [[{'w': 330, 'h': 2393, 'tag': 8, 'unit': 2, 'xres': [-72, 1], 'yres': [-300, 1]}, None], [{'w': 3687, 'h': 735, 'tag': 8, 'unit': 3, 'xres': [-72, 1], 'yres': [1000, 3]}, None], [{'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': 690, 'h': 269, 'xres': [40, 1], 'yres': [72, 1]}, [4382, 949]], [{'w': 2499, 'h': 800, 'tag': 6, 'xres': [150, 2]}, [2709, 8463]], [{'w': 2753, 'h': 567, 'tag': 1, 'unit': 2, 'xres': [150, 2], 'yres': [-300, 1]}, None]]]
labels = ["regression: rational sign validation", "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: rational sign validation 0 | None | None | Passed |
| repair trap 1 | None | None | Passed |
| combined fault 2 | [3150, 1905] | [3150, 1905] | Passed |
| control 3 | [1372, 5475] | [1372, 5475] | Passed |
| control 4 | [302, 892] | [302, 892] | Passed |
| boundary 5 | [2723, 904] | [2723, 904] | Passed |
| boundary 6 | [22168, 495] | [22168, 495] | Passed |
| control 7 | None | None | Passed |
SHA-256 / 842bcdc08110e161e733c38f39038abc6f9fd89fb62b45faf4b0d7620de5cbdb
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.515935+00:00.
Case digest / d68e836750d8dc783da0651ab986526c538f14d2763493cc91f51d31a2686956