From 4b0ef68be03ebbe9da56520d62ce372f66a2a12f Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Thu, 4 May 2023 22:54:48 +0330 Subject: update --- identicon/gen_blockie.py | 90 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100755 identicon/gen_blockie.py (limited to 'identicon/gen_blockie.py') diff --git a/identicon/gen_blockie.py b/identicon/gen_blockie.py new file mode 100755 index 0000000..60d56e0 --- /dev/null +++ b/identicon/gen_blockie.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python + +import argparse +import blockies + + +class Argparser: # pylint: disable=too-few-public-methods + """Argparser class.""" + + def __init__(self): + self.parser = argparse.ArgumentParser() + self.parser.add_argument( + "--seed", + "-s", + type=str, + help="seed phrase", + default="", + ) + self.parser.add_argument( + "--out", + "-o", + type=str, + help="output path", + default="./identicon.png", + ) + self.parser.add_argument( + "--fgcolor", + "-f", + type=str, + help="foreground color", + default=None, + ) + self.parser.add_argument( + "--bgcolor", + "-b", + type=str, + help="background color", + default=None, + ) + self.parser.add_argument( + "--spotcolor", + "-p", + type=str, + help="spot color", + default=None, + ) + self.parser.add_argument( + "--size", + "-z", + type=int, + help="size of image, in blocks", + default=10, + ) + self.parser.add_argument( + "--scale", + "-c", + type=int, + help='size of individual "pixels"', + default=100, + ) + self.args = self.parser.parse_args() + + +def main() -> None: + argparser = Argparser() + if argparser.args.seed == "": + with open( + "../terminaldweller.com/main/srv/.well-known/openpgpkey/hu/gpg_pubkey.asc", + mode="rb", + ) as gpg_pubkey: + key_content = gpg_pubkey.read() + + data = blockies.create(str(key_content), size=10, scale=100) + with open("identicon.png", "wb") as png: + png.write(data) + else: + data = blockies.create( + argparser.args.seed, + size=argparser.args.size, + scale=argparser.args.scale, + color=argparser.args.fgcolor, + bgcolor=argparser.args.bgcolor, + spotcolor=argparser.args.spotcolor, + ) + with open(argparser.args.out, "wb") as png: + png.write(data) + + +if __name__ == "__main__": + main() -- cgit v1.2.3