so maybe do a
$pip install PIL
beforehand
import argparse
import PIL.Image
import PIL.PngImagePlugin
def extract_text(filename):
"""Extracts text from a PNG file."""
img = PIL.Image.open(filename)
info = img.text["workflow"]
return info
## usage python readpng.py ~/Downloads/example.png > comfy_workflow.json
def main():
"""Parses arguments and extracts text from a PNG file."""
parser = argparse.ArgumentParser(description="Extracts text from a PNG file.")
parser.add_argument("filename", help="The PNG file to extract text from.")
args = parser.parse_args()
text = extract_text(args.filename)
print(text)
if __name__ == "__main__":
main()
No comments:
Post a Comment