DEV Community

Fahad Farid
Fahad Farid

Posted on

How I strip photo metadata without a server

Your phone embeds a small diary in every photo: GPS coordinates, camera model, timestamps. Most “metadata remover” sites ask you to upload that diary to their server first — which rather defeats the purpose.

I build ToolVero, a set of 70+ free tools that run entirely in your browser, and the image metadata remover takes the opposite approach: the photo never leaves the device. Here’s the whole trick.

The method: decode, then re-encode from pixels

EXIF, GPS and XMP all live in the JPEG’s metadata segments — they are not part of the image data itself. So instead of surgically deleting segments, we throw the container away:

  1. Decode the uploaded JPEG into a canvas bitmap (pixels only — the browser’s image decoder does not carry EXIF into the bitmap).
  2. Create a fresh PNG from those pixels with canvas.toBlob('image/png').
  3. Offer that PNG as the download, under a neutral filename.

A PNG produced this way contains only IHDR, IDAT and IEND chunks. There is simply nowhere for EXIF to hide, because we never copied the original file’s segments — we re-created the image from raw pixels.

const img = await createImageBitmap(file);   // pixels only, no EXIF
const canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
canvas.getContext('2d').drawImage(img, 0, 0);
const clean = await new Promise(r => canvas.toBlob(r, 'image/png'));
// `clean` is a fresh PNG: IHDR + IDAT + IEND, zero metadata segments
Enter fullscreen mode Exit fullscreen mode

Why the output is clean by construction

PNG has no EXIF segment to preserve, and this method never copies the original file’s metadata segments at all — only the pixels. So EXIF, GPS and XMP have nowhere to survive. (Re-encoding to JPEG via canvas is equally clean, since canvas never writes EXIF — but PNG is the safer default because the format itself can’t carry the metadata.)

Why client-side matters

The privacy win isn’t just the stripped file — it’s that the stripping happens on your machine. No upload means no transit interception, no server logs, no “we delete after 24 hours” promises to trust. For a privacy tool, the architecture is the feature.

Try it on your own photos: Image Metadata Remover — everything runs locally in the tab.

Top comments (0)