Created
April 4, 2023 13:15
-
-
Save dsully/796b452805e349ed584a17e3e61db447 to your computer and use it in GitHub Desktop.
Script to pull PNG Info from Stable Diffusion generated images.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import click | |
import json | |
from PIL import Image | |
@click.command() | |
@click.argument("filename") | |
def main(filename: str) -> None: | |
im = Image.open(filename) | |
im.load() | |
for key in ("sd-metadata", "parameters"): # InvokeAI, automatic1111 | |
if key in im.info: | |
if key == "sd-metadata": | |
print(json.dumps(json.loads(im.info[key]), indent=4)) | |
else: | |
print(im.info[key]) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment