# Removing the generation signature from Stable Diffusion output

Source: https://passreal.com/generators/stable-diffusion

Stable Diffusion leaves two separate traces. The PNG carries a text chunk holding the model, sampler, seed and full prompt. The pixels carry a periodic residue from the VAE decode and any upscaling step. PassReal removes the first outright and attenuates the second with a low-pass filter at 0.88 of Nyquist, then writes camera metadata in its place.

## Two traces, two different problems

It helps to separate what Stable Diffusion writes from what it leaves. They are
found by different tools, they matter to different reviewers, and only one of
them is fully solvable.

What it writes is a text field. Automatic1111 puts the whole generation string
into a PNG tEXt chunk; ComfyUI embeds the workflow graph as JSON. Anyone who
opens the file in exiftool, or drags it into a metadata viewer, sees the model
name and the prompt. There is no ambiguity to argue about and no statistics to
dispute. This part is entirely mechanical, and stripping the chunk removes it
completely.

What it leaves is structure in the pixels. The latent representation is decoded
by a VAE at a fixed factor, which imposes a periodic component on the output.
If the workflow includes a hires fix or an external upscaler, a second periodic
component lands on top. Neither is visible at normal viewing distance. Both are
plainly measurable with a two-dimensional Fourier transform, where they appear
as regularly spaced peaks that photographs do not have.

## Why an empty file is also a signal

The instinct after learning about the text chunk is to strip metadata and stop
there. That produces a file with no metadata whatsoever, which is not what a
camera produces. Every phone and every body writes make, model, exposure time,
aperture, ISO, focal length and a timestamp. A JPEG carrying none of that is
unusual enough to be worth a second look, and a reviewer who has seen a few
stripped files recognises the pattern quickly.

Replacing metadata is therefore part of the job, not a flourish. The pipeline
writes a coherent EXIF block: a specific body, a lens that was actually sold for
that mount, an exposure triple in a plausible range for the scene, and a capture
timestamp. Coherence matters more than any single field, because contradictions
are what get noticed - a 200 mm focal length paired with a phone body, or an
aperture the lens does not have.

## The quantization table nobody checks until they do

A JPEG stores its own quantization tables in the file header. Camera
manufacturers use tables specific to their bodies, distinct from the reference
table in the JPEG standard that most software libraries use by default. That
makes the table a usable fingerprint: forensic tools maintain databases mapping
tables to devices.

A file that claims a Canon body in EXIF while carrying the library's standard
table is stating two incompatible things about its own origin. The pipeline
avoids that by writing the measured table for the make it declares, so the
compression and the claim agree.

## Turning the writing off at the source

If the files never carry the string, there is nothing to strip later.

- In Automatic1111, the setting is under Settings, Saving images, and it
  controls whether generation parameters are written into the PNG.
- In ComfyUI, launching with `--disable-metadata` stops both the prompt and the
  workflow from being embedded.
- Either way, keep a separate record. Losing the seed and settings for an image
  you want to iterate on is a worse problem than the metadata was.

This handles new work and does nothing for the archive. Anything generated
before the setting changed still carries its chunk, so a pass over existing
files is still needed once.

## What the frequency stage does and does not do

The low-pass filter at 0.88 of Nyquist attenuates the periodic residue
without visibly softening the image. Attenuates, not erases: pushing the cutoff
lower removes more structure and starts costing visible sharpness, and the
setting sits where it does because that trade was measured rather than guessed.

Sensor grain at intensity 0.018 is applied before the filter, giving the image
a noise floor. The order matters - grain applied after smoothing would sit on
top of the filtered spectrum as an obviously synthetic high-frequency layer,
rather than being part of the image the filter acts on.

## Questions

### Where does Stable Diffusion store the prompt?

In a PNG tEXt chunk, usually keyed `parameters`, holding the prompt, negative prompt, sampler, steps, CFG scale, seed, model hash and often the exact checkpoint filename. Automatic1111 and ComfyUI both write it by default, and ComfyUI additionally embeds the full node graph.

### Does saving as JPEG remove it?

It removes the PNG chunks, because JPEG has no equivalent container for them, but it removes nothing else. The result is a JPEG with no EXIF at all, which is its own anomaly: cameras and phones always write EXIF, so an image with none stands out from ordinary photographs.

### Does this work on SDXL as well as 1.5?

Yes, and the processing is the same. The residue differs between them because SDXL decodes at a higher native resolution, so its periodic component sits at a different frequency. The low-pass filter is defined relative to Nyquist rather than to a fixed pixel period, so it tracks the change.

### What about images that went through an upscaler?

An upscaling pass adds interpolation residue on top of the generation residue, and the two do not sit at the same frequency. The filter attenuates both, but an image upscaled four times from a small render carries more structure than the pipeline can fully absorb.

### Does a LoRA or a fine-tune change what is left behind?

It changes the picture, not the plumbing. The VAE decode and the file writing are the same, so the metadata trace and the frequency residue are unchanged. What a fine-tune does affect is subject-level plausibility, which no pixel processing addresses.

Try it: https://passreal.com/app (three images free)
