Fixing Corrupted JPG and PNG Files in the Browser with Rust and WebAssembly
Many images that fail to open in viewers like Windows Photos or Photoshop still have intact pixel data, with only framing markers, metadata, or checksums damaged during transfer or recovery. The article explains JPEG structure, including the SOI, APP1, and EOI markers, and common faults such as stray leading bytes, malformed EXIF segments, and missing end-of-image trailers. It also describes PNG's 8-byte signature and per-chunk CRC32 checks, which cause strict decoders to reject files with a single flipped bit or truncated IEND chunk. The author presents a client-side Rust and WebAssembly tool that diagnoses and repairs these files in the browser, so private photos are never uploaded. The piece further notes that many format errors are really wrong file extensions, which can be detected by inspecting magic bytes.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in