Urgent.News

What's breaking now, across thousands of outlets.

Tech

Parsing and Stripping EXIF Metadata Completely In-Browser with JavaScript ArrayBuffers

Every smartphone photo you take embeds precise metadata inside the file: GPS latitude and longitude, camera serial numbers, lens focal lengths, and timestamps. When users look for an online tool to check or clean this data before sharing an image, 95% of web utilities ask them to upload their private photo to an external backend server. From a privacy standpoint, uploading a sensitive photo to a…

Smartphone photos embed GPS metadata, camera specs, and timestamps in their files. However, most online tools requiring users to upload photos to a remote server to scrub this data is a privacy concern. A common frontend approach—loading an image onto an HTML5 canvas and calling canvas.toBlob( image/jpeg )—also alters the image quality via compression.

To address this, ScanMetadata was engineered to run entirely in the browser's memory using ArrayBuffer and DataView. This method parses and strips EXIF data losslessly without altering the image quality.

A JPEG file is composed of sequential binary blocks known as segments, each starting with a two-byte marker (0xFF followed by a marker code). The Start of Image (SOI) marker (0xFFD8) marks the beginning, while the End of Image (EOI) marker (0xFFD9) marks the end. Between these markers, the APP1 segment holds EXIF metadata, including camera settings and GPS coordinates.

The APP0 segment contains the standard JFIF header, while the DQT and SOF markers represent quantization tables and frame headers, respectively. The SOS marker (0xFFDA) signals the beginning of the actual compressed image payload.

To safely inspect metadata without loading the entire file, the File API, FileReader, or file.arrayBuffer() slice can read a portion of the file into a DataView. The function locateExifSegment reads the first 128KB of the file to locate headers quickly. It then validates the SOI marker (0xFFD8) to ensure the file is a valid JPEG.

The function then iterates through the segments, checking for the APP1 marker (0xFFE1), which indicates the presence of EXIF data. Once found, it retrieves the segment length and returns the start offset and total length of the EXIF segment.

Once the EXIF segment is located, the TIFF header is parsed to determine the file's endianness (Little-Endian or Big-Endian). The TIFF header's first two bytes indicate the byte alignment. The function uses DataView to read the endian tag and checks if it matches the Intel (0x4949) or Motorola (0x4D4D) formats. The correct endianness is crucial for accurately interpreting the tag pointers and GPS coordinates. If the TIFF header format is invalid, an error is thrown.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Why PDF image extractors return the stored picture, not the one on the page

Every extractor I pointed at my test PDF gave me back a rotated picture unrotated and a half-hidden picture whole. After three years of codec work I took that as the correct answer, but I wanted to be…

  • PDF image extractors return stored picture, not visible page image
  • Tools like pdfimages, PyMuPDF, pdf.js show stored pixels
  • D image returns page colors, applying /Decode and ignoring clip

A copyable MCP tool-cost check for CI, with passing and failing examples

A tool's description can shrink while its schema grows. A single token total can hide that regression. Here is a complete example that checks the total, descriptions and input schemas separately, then…

  • Tool cost regression detected by CI check
  • HISTOR tool lists verified for expected counts and digests
  • CI integration with baseline snapshot for ongoing monitoring

We collected 1,045 hours of sleep audio. Only 53 hours were usable for training.

We have 1,045 hours of overnight bedroom audio. For training a sleep-phase model, about 53 of those hours are usable. That ratio is the least glamorous number in this project and probably the most…

  • 1,045 hours of sleep audio collected for model training
  • Only 53 hours of audio deemed usable for training
  • Strict criteria resulted in 20:1 ratio of collected to usable data

More from Sunday 25 October →