FAILURE MAP
← Case archive

FA-79026 / Image orientation metadata / Open access

Stale XMP orientation overrides EXIF · case 01

After an in-camera rotation the photo displays with the old XMP orientation.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

XMP is consulted before EXIF, reversing the stated precedence.

THE FAILURE

XMP is consulted before EXIF, reversing the stated precedence.

Unsuccessful approach: Preferring XMP just for PNG still violates the precedence for PNG eXIf data.

Case contract

Resolve the displayed orientation tag from metadata sources. For HEIF, the container transforms are authoritative and EXIF/XMP are ignored: irot is anticlockwise quarter turns (default 0) applied first, then imir mirrors about the vertical axis (0, left-right) or the horizontal axis (1, top-bottom); the result is mapped to a tag through (k clockwise quarter turns after m mirrors) = {(0,0):1, (0,1):2, (2,0):3, (2,1):4, (3,1):5, (1,0):6, (1,1):7, (3,0):8}. For other containers a valid integer EXIF value 1..8 wins; otherwise an XMP string that is a single digit 1..8 after trimming whitespace; otherwise 1.

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(meta):
    from_km = {(0, 0): 1, (0, 1): 2, (2, 0): 3, (2, 1): 4, (3, 1): 5, (1, 0): 6, (1, 1): 7, (3, 0): 8}
    c = meta.get('container')
    if c == 'heif':
        rot = meta.get('irot')
        mir = meta.get('imir')
        rot = 0 if rot is None else rot % 4
        if mir is None:
            return from_km[((-rot) % 4, 0)]
        if mir == 0:
            return from_km[(rot, 1)]
        return from_km[((rot + 2) % 4, 1)]
    x = meta.get('xmp')
    if isinstance(x, str):
        s = x.strip()
        if s in ('1', '2', '3', '4', '5', '6', '7', '8'):
            return int(s)
    e = meta.get('exif')
    if isinstance(e, int) and not isinstance(e, bool) and 1 <= e <= 8:
        return e
    return 1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[{'container': 'png', 'exif': 1, 'xmp': '2'}, 1], [{'container': 'png', 'exif': 7, 'xmp': ' 8'}, 7], [{'container': 'png'}, 1], [{'container': 'jpeg', 'xmp': '2'}, 2], [{'container': 'heif', 'xmp': '\t5', 'irot': 3}, 6], [{'container': 'tiff'}, 1], [{'container': 'tiff', 'exif': True, 'xmp': '7 '}, 7], [{'container': 'png', 'exif': 7, 'xmp': '6'}, 7]], [[{'container': 'png', 'exif': 6, 'xmp': '7 '}, 6], [{'container': 'png', 'exif': 2, 'xmp': '\t5'}, 2], [{'container': 'png', 'xmp': '3\n'}, 3], [{'container': 'jpeg', 'exif': 0, 'xmp': '\t5'}, 5], [{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'jpeg', 'xmp': '3\n'}, 3], [{'container': 'heif', 'exif': 5, 'xmp': ' 8', 'imir': 0}, 2], [{'container': 'jpeg', 'exif': 1, 'xmp': '3\n'}, 1]], [[{'container': 'tiff', 'exif': 8, 'xmp': '7 '}, 8], [{'container': 'png', 'exif': 7, 'xmp': ' 8'}, 7], [{'container': 'png', 'exif': 1, 'xmp': ' 8'}, 1], [{'container': 'jpeg', 'xmp': '7 '}, 7], [{'container': 'tiff'}, 1], [{'container': 'jpeg'}, 1], [{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'jpeg', 'exif': 7, 'xmp': '6'}, 7]], [[{'container': 'jpeg', 'exif': 1, 'xmp': '\t5'}, 1], [{'container': 'png', 'exif': 5, 'xmp': '3\n'}, 5], [{'container': 'png', 'exif': 3, 'xmp': '7 '}, 3], [{'container': 'jpeg', 'exif': True, 'xmp': ' 8'}, 8], [{'container': 'jpeg', 'exif': 1}, 1], [{'container': 'heif', 'exif': 1, 'xmp': '7 ', 'irot': 2}, 3], [{'container': 'heif', 'xmp': '\t5'}, 1], [{'container': 'tiff', 'exif': 8, 'xmp': '\t5'}, 8]], [[{'container': 'jpeg', 'exif': 7, 'xmp': '\t5'}, 7], [{'container': 'png', 'exif': 6, 'xmp': '7 '}, 6], [{'container': 'png', 'exif': 5, 'xmp': ' 8'}, 5], [{'container': 'png', 'xmp': '7 '}, 7], [{'container': 'heif', 'irot': 2}, 3], [{'container': 'heif', 'xmp': ' 8', 'irot': 1}, 8], [{'container': 'jpeg', 'xmp': 'x'}, 1], [{'container': 'png', 'exif': 2, 'xmp': '3\n', 'irot': 0, 'imir': 1}, 2]]]
labels = ["regression: EXIF over XMP precedence", "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 fixtureActualExpectedOutcome
regression: EXIF over XMP precedence 021Failed
repair trap 187Failed
combined fault 211Passed
control 322Passed
control 466Passed
boundary 511Passed
boundary 677Passed
control 767Failed

SHA-256 / bcc442f91e46c77dd6d0dbd22e64cdca7e1b76f501e9cc102b213c07eadd041c

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(meta):
    from_km = {(0, 0): 1, (0, 1): 2, (2, 0): 3, (2, 1): 4, (3, 1): 5, (1, 0): 6, (1, 1): 7, (3, 0): 8}
    c = meta.get('container')
    if c == 'heif':
        rot = meta.get('irot')
        mir = meta.get('imir')
        rot = 0 if rot is None else rot % 4
        if mir is None:
            return from_km[((-rot) % 4, 0)]
        if mir == 0:
            return from_km[(rot, 1)]
        return from_km[((rot + 2) % 4, 1)]
    x = meta.get('xmp')
    if c == 'png' and isinstance(x, str) and x.strip() in ('1', '2', '3', '4', '5', '6', '7', '8'):
        return int(x.strip())
    e = meta.get('exif')
    if isinstance(e, int) and not isinstance(e, bool) and 1 <= e <= 8:
        return e
    if isinstance(x, str):
        s = x.strip()
        if s in ('1', '2', '3', '4', '5', '6', '7', '8'):
            return int(s)
    return 1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[{'container': 'png', 'exif': 1, 'xmp': '2'}, 1], [{'container': 'png', 'exif': 7, 'xmp': ' 8'}, 7], [{'container': 'png'}, 1], [{'container': 'jpeg', 'xmp': '2'}, 2], [{'container': 'heif', 'xmp': '\t5', 'irot': 3}, 6], [{'container': 'tiff'}, 1], [{'container': 'tiff', 'exif': True, 'xmp': '7 '}, 7], [{'container': 'png', 'exif': 7, 'xmp': '6'}, 7]], [[{'container': 'png', 'exif': 6, 'xmp': '7 '}, 6], [{'container': 'png', 'exif': 2, 'xmp': '\t5'}, 2], [{'container': 'png', 'xmp': '3\n'}, 3], [{'container': 'jpeg', 'exif': 0, 'xmp': '\t5'}, 5], [{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'jpeg', 'xmp': '3\n'}, 3], [{'container': 'heif', 'exif': 5, 'xmp': ' 8', 'imir': 0}, 2], [{'container': 'jpeg', 'exif': 1, 'xmp': '3\n'}, 1]], [[{'container': 'tiff', 'exif': 8, 'xmp': '7 '}, 8], [{'container': 'png', 'exif': 7, 'xmp': ' 8'}, 7], [{'container': 'png', 'exif': 1, 'xmp': ' 8'}, 1], [{'container': 'jpeg', 'xmp': '7 '}, 7], [{'container': 'tiff'}, 1], [{'container': 'jpeg'}, 1], [{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'jpeg', 'exif': 7, 'xmp': '6'}, 7]], [[{'container': 'jpeg', 'exif': 1, 'xmp': '\t5'}, 1], [{'container': 'png', 'exif': 5, 'xmp': '3\n'}, 5], [{'container': 'png', 'exif': 3, 'xmp': '7 '}, 3], [{'container': 'jpeg', 'exif': True, 'xmp': ' 8'}, 8], [{'container': 'jpeg', 'exif': 1}, 1], [{'container': 'heif', 'exif': 1, 'xmp': '7 ', 'irot': 2}, 3], [{'container': 'heif', 'xmp': '\t5'}, 1], [{'container': 'tiff', 'exif': 8, 'xmp': '\t5'}, 8]], [[{'container': 'jpeg', 'exif': 7, 'xmp': '\t5'}, 7], [{'container': 'png', 'exif': 6, 'xmp': '7 '}, 6], [{'container': 'png', 'exif': 5, 'xmp': ' 8'}, 5], [{'container': 'png', 'xmp': '7 '}, 7], [{'container': 'heif', 'irot': 2}, 3], [{'container': 'heif', 'xmp': ' 8', 'irot': 1}, 8], [{'container': 'jpeg', 'xmp': 'x'}, 1], [{'container': 'png', 'exif': 2, 'xmp': '3\n', 'irot': 0, 'imir': 1}, 2]]]
labels = ["regression: EXIF over XMP precedence", "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 fixtureActualExpectedOutcome
regression: EXIF over XMP precedence 021Failed
repair trap 187Failed
combined fault 211Passed
control 322Passed
control 466Passed
boundary 511Passed
boundary 677Passed
control 767Failed

SHA-256 / c2613b79493037abe74df91038a40a687e19df052e03eebca668580caa56d197

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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.556807+00:00.

Case digest / 8b20333a0c74e52d5ee80c6cf4740dce4b1df4ded7997b4a92db8fbb05b62741