Notes › Tech Notes › Two EXIF Segments in One Photo, but the Web Viewer Only Reads the First One's 12 Tags

Two EXIF Segments in One Photo, but the Web Viewer Only Reads the First One's 12 Tags

Measured with the page's own parser: a hand-built 524 B JPEG with two APP1 segments shows only the first one's 12 tags; each broken header leaves its own warning line, a zero denominator falls back to 1, maker-private data reports size only, and the PNG and TIFF size counters disagree.

It Started with a 524-Byte JPEG

When a single photo carries two EXIF segments, which one does the web viewer recite? I hand-built a 524 B JPEG sample whose segment order is APP0 (JFIF), first APP1-EXIF, second APP1-EXIF, APP1-XMP, COM, SOS; the measured segment table registers 6 segments and both same-kind APP1 blocks are present. They differ only in the maker tag: segment one says "AAA", segment two says "BBB". The page summary reads out only "AAA", and "BBB" appears exactly nowhere in any output. The tag groups total 1 group with 12 tags, the metadata size count is 493 B; XMP travels a separate channel and yields 1 field. One glance at the segment-picking loop explains the behavior: the first exif segment wins, and the ones behind it never overwrite. Every number below comes from loading the template's script section verbatim into Node and calling the page's own parsing functions; no browser was opened at any point.

Segment table of the hand-made 524 B sample: 6 rows, first EXIF only APP0 APP1 APP1 XMP COM SOS JFIF AAA wins BBB missing own channel HELLOCOM 1 group of 12 tags · count 493 B · XMP adds 1 field Segment loop: first exif segment wins, later ones never overwrite

Figure 1: two same-kind APP1 segments coexist, and the page deals the card only to the first one.

Four Broken Headers, Four Different Messages

What does the page say when offsets or byte order rot? I built one sample per failure mode:

Input constructionPage warningResult shape
TIFF header written as "IM*", neither II nor MMEXIF data header is not II/MM, parsing skipped0 groups, and no error either
Header says II, but the IFD is assembled big-endianInvalid IFD position (134217728)The whole directory is dropped in silence
Tag count written as 200, data offset written as 100000Data of tag 0x10F is out of bounds, its value was skippedThe row still lists, with an empty-string value
TIFF version number written as 45TIFF version is 45 (normally 42 or 43), still parsed as EXIFValues read out as usual

Both of the first two failures leave a single warning line and never escalate to error, so in the rendered list they look like "read something, but there is nothing there"; when you reconcile the ledger you have to keep the warning lines in the same view.

Rational Tags: Even a Zero Denominator Gets Caught

Four type-5 rational pairs sat in the little-endian IFD. 1/60 displays as "1/60 sec", because values under 1 fold into 1/round(reciprocal); 28/10 displays as "f/2.8", keeping 1 decimal; 1/0 displays as "f/1" — both the decoding site and the evaluation site swap a zero denominator for 1 as a fallback, so nothing throws and no infinity ever prints; 0/5 displays as "f/0". Arrays run on a different rule: the 5 rationals display as "0.333, 0.667, 1, 1.5... (5 total)", each value rounded to 3 decimals, truncated past the fourth one. In a big-endian MM file the same 1/125 still reads "1/125 sec", and no fraction reduction happens anywhere.

Maker Notes and Off-Table Tags

Tag 0x927C stuffed with 96 bytes of 0xAB still only earns one row: "96 B of maker-private data (formats differ by brand, the tool does not parse the content)", with zero interpretation of the payload beyond that size line. An off-map 0xABCD is not hidden either; it is honestly listed as "0xABCD | unrecognized tag". One display-layer blemish: tag numbers print in hex without zero padding, so inside the same 12-row list the maker reads 0x10F and the description reads 0x10E, five rows in total show the three-digit shape, and they never line up with the spec-style 0x010F; when you search tag numbers you have to remember both spellings.

The Character Set Has Only Two States

Four strings placed into one IFD, measured: ASCII "AAA" returns untouched; the UTF-8 bytes E4 B8 AD E6 96 87 restore the two Chinese characters correctly; UTF-16LE with its BOM (FF FE 41 00 42 00) gets cut at the first NUL, then strict decoding fails and it degrades into the byte-per-byte "ÿþA"; the GBK bytes D6 D0 CE C4 degrade the same way into "ÖÐÎÄ". The page knows exactly two states, UTF-8 succeeds or every byte falls back — there is no UTF-16 branch and no GBK branch, so whether a Chinese description renders cleanly or turns into mojibake depends entirely on which encoding the writing side happened to use.

Switch Containers: Same Parsing Road or Not

For PNG I fed the signature plus IHDR(8x10), one eXIf chunk whose CRC fields are written entirely as 0, a tEXt chunk, and IEND: parsing succeeded with 1 tag out and a metadata count of 63 B — chunk reading checks CRC not at all. For WebP I fed RIFF plus VP8 plus an EXIF chunk, success, count 34 B. A whole TIFF file goes straight in and all 12 tags come out, yet the metadata size count is 0: the size function only sums the container segment list, and a file-level TIFF enters no ledger at all. HEIC has a branch, but a 12-byte ftyp already gets the fixed answer "this tool does not parse it". The GIF branch exists in the function list; I did not build a sample this round, so it stays unmeasured.

Reading branches per container: tags come out, size ledgers disagree JPEG: 1 group of 12 tags, count 493 B PNG: 1 tag, count 63 B, CRC 0 still reads WebP: read ok, count 34 B TIFF: all 12 tags out, count 0 HEIC: 12-byte ftyp, refuses parsing GIF: branch exists, no sample built Whole-file TIFF skips the size function Size ledger only sums container segments

Figure 2: four roads that do read tags out, and one size ledger that does not add up.

What Empty Files and Bad Headers Say

A 0-byte file and a 16-byte random stream come back with the very same verbatim error: "unrecognized image format (file header matches none of JPEG/PNG/WebP/GIF/TIFF)". The filename suffix plays no part in the decision. A bare JPEG without metadata (SOI+SOS+EOI) is success with an empty table at the parsing layer: 0 groups, 0 B, no error. For the empty table, the rendering layer's fallback line is verified statically against the template; the browser click state was not measured.

The Page Does More Than Show

The button area has four exits whose captions, verbatim, are clear the list, download the current image (cleaned), package-download everything, and copy the current image info. The write-back and packing chain that rewrites bytes names 11 functions statically inside the template. Inside the 1025-line reading slice the input only ever receives subarray and slice copy reads, with no indexed write-back, and the parsed product is just an in-memory object. So the reading half never touches your bytes; whether an uploaded original file gets altered comes down to those exit buttons, and reading this function ledger beats reading any slogan about safety.

Cross References

The page measured here is the photo info viewer itself; how orientation tags divide their work with a real pixel rotation is measured in a dedicated article and is not repeated in this one; if you want to touch the image body itself or move it into another container format, go to the image format conversion page.

Q: both EXIF segments are inside, why recite only the first one?

The segment loop is written as first exif segment wins, later ones never overwrite. In the 524 B sample the segment table registers 6 rows and both same-kind APP1 blocks exist, yet the summary maker reads only "AAA", "BBB" appears in no output at all, and the tag groups stay 1 group of 12.

Q: does a broken file header always raise an error?

Not necessarily. The "IM*" header and the out-of-bounds data reference each leave only a warning line: the first gives 0 groups with no error, the second still lists its row with an empty value; even a version number of 45 reads values out as usual. Only when the file header matches none of the five containers does that verbatim error line appear.

Q: will Chinese description tags turn into mojibake?

It depends on the writer's encoding. The UTF-8 sample restored cleanly, while the UTF-16LE and GBK samples both degraded into byte-per-byte fallback shapes; the page carries no branches for those two character sets, so the fallback is the standing state, not an accident.

📎 Related articles

Text Set Operations Measured: Duplicates and Order 2026-11-28 HTML Beautify Deletes the Blank Line Inside pre 2026-11-28 Why 1 GB at 100 Mbps Shows 1 min 29 sec: The Divide by 8 and the 90 Percent Discount on This Page 2026-11-27 Standard Deviation Calculator, Two Conventions Measured: Sample 5.12696 vs Population 4.795832 at 1.069045 Times 2026-11-27 Same 90/80 as 30/70, 3/7 or 0.3/0.7 Gives 83, but the Contribution Column Sums to 0.9999 2026-11-27