mirror of
https://github.com/e1ven/Robohash.git
synced 2025-06-23 21:35:02 +00:00

Some users have asked for an updated version in PyPI, so I'm doing some minor cleanup. No real functionality changes, just modernizing things that would be considered more standard 10+ years after this code was written. - Added note about maintenance mode in README - Cleaned up Python 3 compatibility (removed Python 2 support) - Added minimal test for image consistency - Added Docker image + GitHub workflow to build/publish it - Fixed some minor bugs and improved error handling - Added better CLI help text The project is now officially in maintenance mode as noted in the README.
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
import argparse
|
|
import io
|
|
import sys
|
|
from typing import NoReturn
|
|
from robohash import Robohash
|
|
|
|
|
|
def main() -> NoReturn:
|
|
"""
|
|
Command-line interface for Robohash.
|
|
Parses arguments and generates a robot image based on input text.
|
|
"""
|
|
parser = argparse.ArgumentParser(description="Generate a robot hash image from text input")
|
|
parser.add_argument("-s", "--set", default="set1", help="Robot set to use (set1, set2, set3, set4, set5, or 'any')")
|
|
parser.add_argument("-x", "--width", type=int, default=300, help="Width of output image")
|
|
parser.add_argument("-y", "--height", type=int, default=300, help="Height of output image")
|
|
parser.add_argument("-f", "--format", default="png", help="Output format (png, jpeg, etc.)")
|
|
parser.add_argument("-b", "--bgset", help="Background set to use (bg1, bg2, or 'any')")
|
|
parser.add_argument("-o", "--output", default="robohash.png", help="Output filename")
|
|
parser.add_argument("text", help="Text to use for the hash")
|
|
|
|
args = parser.parse_args()
|
|
|
|
robohash = Robohash(args.text)
|
|
robohash.assemble(
|
|
roboset=args.set,
|
|
bgset=args.bgset,
|
|
sizex=args.width,
|
|
sizey=args.height,
|
|
format=args.format
|
|
)
|
|
|
|
robohash.img.save(args.output, format=args.format)
|
|
sys.exit(0)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|