Read a Stable Diffusion PNG's Prompt and Seed

Some Stable Diffusion interfaces save generation settings as PNG text metadata. In a file with AUTOMATIC1111-style parameters, you may recover the prompt, sampler, seed and other settings. Start with the original download, since copying only the pixels can discard that information.

Worked example

Create two tiny PNG metadata fixtures

from PIL import Image, PngImagePlugin

image = Image.new("RGB", (8, 8), "navy")
info = PngImagePlugin.PngInfo()
info.add_text("parameters", "paper boat\nSteps: 20, Sampler: Euler, CFG scale: 7, Seed: 4242")
image.save("with-info.png", pnginfo=info)
image.save("pixels-only.png")

Steps

  1. Open the original PNG in the PNG Info tool. If parameters are present, copy the entire block to a text file alongside the original image.
  2. If only a resized or shared copy remains, inspect it separately. When the parameter block is missing, ask for the original export or the saved generation settings.
  3. Try the local fixture with Pillow installed. It saves the same pixels once with a parameters text chunk and once without it, so you can compare both files in the inspector.

What to check

  • Compare both files and look for seed 4242 only in with-info.png.
  • Keep model and version details when available. A seed alone is insufficient to reproduce an image.

Open the Stable Diffusion image info tool

References