{
  "id": 19871505,
  "title": "Remove GPS and EXIF from a JPEG in the browser, without re-encoding it",
  "url": "https://urgent.news/2026/11/13/remove-gps-and-exif-from-a-jpeg-in-the-browser-without-re-encoding-it",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-13T21:59:01.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/__a275a1bef4/remove-gps-and-exif-from-a-jpeg-in-the-browser-without-re-encoding-it-5dpa"
  },
  "original_language": "en",
  "account": "Every digital photograph captured by a smartphone contains extra data known as EXIF metadata. This includes information such as the camera model, lens specifications, timestamps, and sometimes even the owner's name. In certain situations, GPS coordinates can also be included. While some platforms automatically eliminate this metadata when a photo is uploaded, many do not. Photos can be shared through various methods like messaging apps, email attachments, shared cloud links, forums, marketplaces, and personal websites. It's generally advisable to assume that metadata travels alongside the file.\n\nIn a previous post, it was demonstrated that inserting an image into a canvas results in metadata being lost as a secondary effect. However, this method does re-encode the JPEG, resulting in a slight loss of quality with each iteration. An alternative approach involves removing the metadata directly from the file, byte by byte, while preserving the image data in its original form.\n\nA JPEG file is composed of several segments, each beginning with a marker consisting of the byte 0xFF followed by a type byte. Most segments are followed by a 2-byte big-endian length, which includes those 2 bytes. Common segments include the Start of Image (SOI) marker (FF D8), the APP0 segment for the JFIF header, the APP1 segment for EXIF (camera, dates, GPS), the APP2 segment for an Adobe XMP (Extensible Metadata Platform), the APP13 segment for Adobe's International Colour Consortium (ICC) colour profile, the APP14 segment for Photoshop/IPTC metadata, and the APP13 segment for Digital JPEG Test Pattern. The image data itself begins after the Start of Frame (SOF) marker (FF C0), followed by Huffman tables (FF DHT) and the Start of Scan (SOS) marker (FF DA), with compressed pixel data following. The End of Image (EOI) marker (FF D9) concludes the file.\n\nTo extract a JPEG image devoid of metadata via a browser, the process involves disassembling the file into segments, discarding the undesired segments, and reassembling the remainder without alteration. Initially, the function `listSegments` is employed to scan through the file's segments, identifying and cataloging each one along with its attributes. A typical phone photo would display an APP1 segment containing EXIF data, which can be quite extensive, often several kilobytes in size, potentially even more due to the inclusion of a thumbnail.\n\nSubsequently, a function named `stripJpegMetadata` is utilized to eliminate the metadata segments from the file. This function first ensures that the input is indeed a JPEG file by checking the initial bytes (0xFF D8). Following this, it processes the segments sequentially, skipping over those that signify metadata (identified by markers such as 0xE1, 0xED, and 0xFE) and retaining all other segments intact. The result is a JPEG file stripped of its metadata while retaining the original image data, achieved without re-encoding the file.",
  "summary": "Every photo from a phone carries a small hidden file inside it: EXIF metadata. Camera model, lens, timestamps, sometimes the owner's name, and, if location was on, GPS coordinates precise enough to find a house. Some platforms strip this when you upload. Many paths don't: sending a photo \"as a file\" in a messenger, email attachments, shared cloud links, forums, marketplaces, your own website. If…",
  "key_points": [
    "JPEG files contain EXIF metadata with camera info, timestamps, GPS.",
    "Browser can remove metadata without re-encoding JPEG file.",
    "Segments are identified, stripped, reassembled in script."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}