Removing metadata without losing quality: why re-encoding is not cleaning
There are two ways to remove a photo’s metadata. One is to take out the data blocks and leave the image as it was. The other is to open the photo, draw it again and save it again: the metadata gets lost along the way, but the image changes too. And sometimes the metadata does not even get lost.
What re-encoding is
A JPEG or a HEIC stores the image with lossy compression: saving it discards information the eye barely notices. If someone opens the photo and saves it again, that compression is applied once more on top of the previous one, and the image loses a little more. Once is hard to see; several times, and blocks, dirty edges and fading colours appear.
Many tools remove metadata exactly this way, because it is the easiest thing to program: they draw the photo on a canvas and export it again. It works, but it is not free.
What we measured
We took a 3024 × 4032 test photo with GPS and processed it three ways. The percentages depend on each photo — one with lots of detail loses more than ours, which is smooth — so what matters is what changes and what does not:
- Redrawing it in the browser, as many simple sites do: 1.8 % of the pixels changed and the file went from 925 to 742 kB. It removed the GPS, but it re-encoded.
- Saving it again with macOS’s image tool (
sips) at quality 85: 16.8 % of the pixels changed and the GPS was kept. Re-encoding is not cleaning. - With KillEXIF: not a single pixel changed. The image data is the same, byte for byte, and the GPS was gone.
- Ten saves in a row at quality 90: the difference from the original grew with each one. That is why not re-encoding matters: every time a photo goes through a tool like that, it loses a little more.
How to tell whether a tool re-encodes
There are clues that need no measuring:
- The size changes a lot. Removing metadata saves a few kilobytes, sometimes a bit more if there was a thumbnail. If a 3 MB photo comes out at 2 MB, it has been recompressed.
- It lets you choose a “quality” when saving. If there is quality, there is compression.
- The format changes: if you put in a HEIC and get a JPEG, the whole image has been encoded again.
- It takes as long as processing the image: removing a metadata block is almost instant; recompressing a large photo is not.
What KillEXIF does
KillEXIF removes metadata without touching the image: it finds the data blocks inside the file, takes them out and copies the rest as it is. Then it reads the clean file back to check that what was meant to go is gone, and says so: “Checked: nothing sensitive left”. And if something cannot be removed without breaking the file, it explains that instead of recompressing it.
That is why the clean photo weighs almost the same as the original, and why you can clean it as many times as you like without it losing anything. The same goes for videos: the metadata goes and the video is not encoded again.