<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[1ucn.com Team blog]]></title><description><![CDATA[1ucn.com Team blog]]></description><link>https://1ucn.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Dec 2026 23:42:49 GMT</lastBuildDate><atom:link href="https://1ucn.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Stripping EXIF/GPS location from photos before sharing — why and how]]></title><description><![CDATA[How photo GPS is stored, how to check for it, and how to strip EXIF with JavaScript or exiftool before you share.]]></description><link>https://1ucn.hashnode.dev/stripping-exif-gps-location-from-photos-before-sharing-why-and-how</link><guid isPermaLink="true">https://1ucn.hashnode.dev/stripping-exif-gps-location-from-photos-before-sharing-why-and-how</guid><category><![CDATA[privacy]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Photography]]></category><category><![CDATA[Security]]></category><dc:creator><![CDATA[1ucn.com Team]]></dc:creator><pubDate>Tue, 24 Nov 2026 00:39:41 GMT</pubDate><content:encoded><![CDATA[<p>A photo of a backyard, a hotel room, or a child's school gate can include the exact coordinates where it was taken. That data is not visible when you look at the picture. It lives in metadata — usually EXIF, sometimes also XMP or IPTC — and it often survives email, AirDrop, a USB transfer, and quite a few "just crop it" edits. This article covers how to check a file and how to strip location with a command-line tool or with JavaScript in the browser, without uploading the photo.</p>
<h2>What is in a photo besides the pixels</h2>
<p><a href="https://www.loc.gov/preservation/digital/formats/fdd/fdd000146.shtml">EXIF</a> (Exchangeable Image File Format) is a set of tags cameras and phones write into JPEG, TIFF, and, these days, HEIC and WebP files. The Library of Congress format description is a solid, sober overview of what the container can hold. Common tags include:</p>
<ul>
<li>Camera make and model, lens, and settings (aperture, shutter, ISO).</li>
<li>The date and time the shutter fired, and sometimes the time zone.</li>
<li>Orientation, so a portrait photo is displayed upright.</li>
<li>A unique image or device identifier, on some phones.</li>
<li>A GPS block: latitude, longitude, altitude, and sometimes a compass direction or a GPS timestamp.</li>
</ul>
<p>The GPS tags are the ones that cause the most harm when they leak. Phil Harvey's <a href="https://exiftool.org/TagNames/GPS.html">ExifTool GPS tag list</a> is the practical reference for names such as <code>GPSLatitude</code>, <code>GPSLongitude</code>, <code>GPSAltitude</code>, and <code>GPSDateStamp</code>. A photo taken at home can point at your street. A photo taken on a morning run can sketch a route. A photo of your child outside school can give away a weekday location.</p>
<p>Location is not the only sensitive field. Timestamps can corroborate when you were somewhere, and a camera serial or unique image ID can tie together photos you thought were unrelated. You do not always need to delete every tag — orientation and a color profile are useful — but you should know they are there.</p>
<h2>Who strips metadata, and who does not</h2>
<p>There is no single rule. Platforms change their behavior, and the same app can treat "send as photo" and "send as document" differently. A reasonable working assumption:</p>
<ul>
<li>Posting into the main feed of a large social network often strips GPS, but do not assume it strips everything, and do not assume a download you later save is clean.</li>
<li>Email attachments, messaging "document" or "file" mode, cloud-drive shares, and AirDrop usually keep metadata intact.</li>
<li>Screenshots typically have no GPS, because they are a grab of the screen, not a camera capture. That does not help if you share the original file next to the screenshot.</li>
<li>Cropping or resizing in a photo editor may rewrite the file and drop EXIF, or it may copy the EXIF into the new file, GPS included. The only way to know is to check the output.</li>
</ul>
<p>Apple documents how to <a href="https://support.apple.com/en-us/118225">turn Location Services off for the Camera</a>, which stops new photos from getting a GPS tag. That setting does not remove location already written into photos you took last year. Those files have to be cleaned separately.</p>
<h2>How to check a file</h2>
<p><strong>On the command line</strong>, <a href="https://exiftool.org/">ExifTool</a> is the standard. Install it, then:</p>
<pre><code class="language-bash"># See whether GPS tags are present
exiftool -gps:all -a -G1 photo.jpg

# See everything, grouped by metadata block
exiftool -a -G1 -s photo.jpg
</code></pre>
<p>If the first command prints latitude and longitude, the file still has a location. Look at more than the primary image: some files also store a thumbnail with its own EXIF, and some store a second copy of the coordinates in XMP. The <code>-a</code> flag shows duplicate tags instead of hiding them.</p>
<p><strong>On a Mac</strong>, open the file in Preview or Photos, open the Inspector or Info panel, and look for a location or map. <strong>On Windows</strong>, right-click the file, open Properties, and check the Details tab for GPS fields. These views miss tags that ExifTool would show, so treat a "blank" panel as incomplete, not as proof.</p>
<p><strong>In JavaScript</strong>, you can test a <code>File</code> or <code>Blob</code> in the browser without sending it anywhere. A dedicated parser is safer than writing JPEG segment code by hand. With the <code>exifr</code> library:</p>
<pre><code class="language-javascript">import exifr from "exifr";

export async function readLocation(file) {
  const gps = await exifr.gps(file);
  const exif = await exifr.parse(file, { pick: ["Make", "Model", "DateTimeOriginal", "Orientation"] });
  return {
    hasGps: Boolean(gps &amp;&amp; gps.latitude != null &amp;&amp; gps.longitude != null),
    gps: gps || null,
    camera: exif || null,
  };
}
</code></pre>
<p><code>exifr.gps()</code> returns decimal latitude and longitude when they exist, or <code>undefined</code> when they do not. That is enough for a pre-share check. If you want to inspect a file once, without building a page around it, a browser-only <a href="https://1ucn.com/photo-location/">photo location</a> reader will parse the GPS in the current tab and not upload the image.</p>
<p>A minimal JPEG check, if you only need to know whether an <code>Exif</code> APP1 segment exists at all, looks like this:</p>
<pre><code class="language-javascript">async function jpegHasExifSegment(file) {
  const buf = new Uint8Array(await file.slice(0, 64 * 1024).arrayBuffer());
  if (buf[0] !== 0xff || buf[1] !== 0xd8) return false; // not a JPEG SOI
  let i = 2;
  while (i + 4 &lt; buf.length &amp;&amp; buf[i] === 0xff) {
    const marker = buf[i + 1];
    const length = (buf[i + 2] &lt;&lt; 8) + buf[i + 3];
    if (marker === 0xe1) {
      const start = i + 4;
      const head = String.fromCharCode(...buf.slice(start, start + 4));
      if (head === "Exif") return true;
    }
    if (length &lt; 2) break;
    i += 2 + length;
  }
  return false;
}
</code></pre>
<p>That snippet only detects an EXIF block in a JPEG. It does not parse GPS, handle HEIC, or see location stored only in XMP. Use it as a tripwire, not as a complete audit.</p>
<h2>How to strip location, carefully</h2>
<p>There are two honest approaches: delete selected tags and keep the rest of the file, or re-encode the pixels into a new file that has no metadata. Each has a cost.</p>
<h3>1. ExifTool, tag by tag</h3>
<p>To remove only the GPS block, leaving camera settings and orientation in place:</p>
<pre><code class="language-bash">exiftool -overwrite_original -gps:all= -xmp:geotag= photo.jpg
</code></pre>
<p>To remove almost all metadata:</p>
<pre><code class="language-bash">exiftool -overwrite_original -all= photo.jpg
</code></pre>
<p><code>-all=</code> is blunt. It can also drop the color profile and the orientation tag, which may change how the photo looks on another device. If you use it, open the result and confirm the picture is still the right way up and that the colors have not shifted. You can be more precise, for example by keeping ICC and orientation:</p>
<pre><code class="language-bash">exiftool -overwrite_original -all= -tagsFromFile @ -icc_profile -orientation photo.jpg
</code></pre>
<p>Then read the file again with <code>exiftool -gps:all -a -G1</code> and confirm there is no latitude left, including in XMP. Do this on a copy first if the photo matters.</p>
<p>For iPhone HEIC files, ExifTool still works, but support depends on your build. If the photo will be shared with people on Windows, converting to JPEG and then checking the JPEG is often more predictable — conversion may drop the tags, or a metadata-preserving library may copy them across. Always re-read the output.</p>
<h3>2. Re-encode in the browser (canvas)</h3>
<p>Drawing the image to a canvas and calling <code>toBlob()</code> produces a new JPEG or WebP with no EXIF. That is effective, and it is also lossy: you are re-compressing the photo, and you must honor orientation when you draw, or a portrait image will come out on its side.</p>
<pre><code class="language-javascript">async function stripByReencoding(file, type = "image/jpeg", quality = 0.92) {
  const bitmap = await createImageBitmap(file, { imageOrientation: "from-image" });
  const canvas = document.createElement("canvas");
  canvas.width = bitmap.width;
  canvas.height = bitmap.height;
  const ctx = canvas.getContext("2d", { alpha: type !== "image/jpeg" });
  ctx.drawImage(bitmap, 0, 0);
  bitmap.close();

  const blob = await new Promise((resolve, reject) =&gt; {
    canvas.toBlob(
      (b) =&gt; (b ? resolve(b) : reject(new Error("toBlob failed"))),
      type,
      quality
    );
  });
  return blob;
}
</code></pre>
<p>After you have the blob, run it back through <code>exifr.gps()</code> and refuse to download it if any coordinates remain. They should not, for a canvas-encoded JPEG, but verification is cheap.</p>
<p>If you only need this occasionally, a local <a href="https://1ucn.com/remove-exif/">EXIF remover</a> that rewrites the file in the current tab is the same idea: the photo stays on the device, and you should still open the result and check that the location is gone.</p>
<h3>3. Surgical edits in JavaScript</h3>
<p>Libraries such as <code>piexifjs</code> can load a JPEG, remove the GPS IFD, and write the JPEG back without re-encoding the pixels. That preserves quality, which the canvas method does not. The limitation is format coverage: piexif-style tools are JPEG-centric. HEIC, PNG <code>eXIf</code> chunks, and WebP EXIF need other parsers. If your pipeline already standardizes on JPEG, surgical removal is the better default. If you receive whatever a phone produces, re-encoding after a <code>createImageBitmap</code> decode is simpler to reason about.</p>
<h2>Verify, then share the cleaned copy</h2>
<p>A few habits prevent the usual mistakes: work on a copy; check the file you are about to attach, not a preview from another app; watch for thumbnails and XMP sidecars if you share a whole folder; and remember that turning off location in the camera app does not clean photos you already took.</p>
<p>Metadata is not hidden in any strong sense. It is just inconvenient to read, which is why it gets shared by accident. Read the file on your own machine, strip the tags you do not want to send, and read it once more. The pixels are what you meant to share. The coordinates usually are not.</p>
]]></content:encoded></item></channel></rss>