Why re-saving an image to strip metadata costs you quality
There are two fundamentally different ways to remove metadata from an image, and the one a tool picks determines whether your output is pixel-identical or quietly degraded.
The easy way: re-encode
The simplest implementation is three lines of code: load the image into a canvas or an imaging library, then save it out again. The metadata disappears because the library only writes back what it knows about, and it does not know about your EXIF block.
It works. It also does the following, whether you wanted it to or not:
- Decompresses your JPEG and recompresses it, introducing a fresh generation of compression artefacts.
- Applies the library's default quality setting, which is very unlikely to match your original.
- Usually discards the ICC colour profile, so wide-gamut images visibly shift.
- Can change chroma subsampling, softening fine coloured detail.
Do this three or four times across a workflow and the cumulative degradation becomes clearly visible — particularly on flat gradients and around high-contrast edges.
The correct way: rewrite the container
Image files are containers. A PNG is a signature followed by a list of length-prefixed chunks. A JPEG is a chain of marker segments. The compressed pixel data lives in specific, identifiable regions; the metadata lives in others.
If you parse that structure, you can copy the pixel regions through untouched and simply skip the metadata regions when reassembling the file. Nothing is decoded. Nothing is recompressed. The output is bit-identical to the input, minus the bytes you deliberately removed.
The trap: APP2 in JPEG
There is one subtlety that a lot of naive implementations get wrong. In JPEG, the APP2 marker is shared. It usually carries the ICC colour profile — but C2PA manifests also appear there.
A tool that drops all APP segments will strip your colour profile along with the manifest, and your image will render with shifted colours in any colour-managed application. The fix is to read the payload identifier at the start of the segment: ICC profiles begin with the ASCII string ICC_PROFILE, so those can be preserved while everything else in that marker is removed.
How to tell which one a tool uses
Two quick checks:
- Compare file sizes. A container rewrite should shrink the file by roughly the size of the metadata removed — no more. A re-encode will change the size unpredictably, often dramatically.
- Check the colour profile survived. If your wide-gamut image looks flat or shifted afterwards, the tool re-encoded and dropped the profile.
PurifyAI takes the container-rewrite approach for PNG and JPEG, and preserves ICC profiles deliberately. Where a format cannot be rewritten safely in a browser, it says so rather than silently falling back to a re-encode.