First, you'll want to set up a virtual Python environment from which to execute the script:
python -m venv badge-generator-venv
or python3 -m venv badge-generator-venv
Now that we have our environment we need to enter it. If you're on Windows simply:
.\badge-generator-venv\Scripts\activate
If you're on Mac OSX, you'll need to source it:
source ./badge-generator-venv/bin/activate
Now you can install the requirements once inside of the virtual environment:
pip install -r requirements.txt
Now you can run the script with the following arguments:
Required:
- -lt (--left_text): the text for the left of the badge
- -rt (--right_text): the text for the right of the badge
Optional:
- -sn (--savename): the name to save the resulting PNG as, defaults to
left_text
right_text
- -fp (--font_path): the path to the true-type font to use for the badge left and right text, defaults to
./fonts/oswald-semi-bold.ttf
- -ts (--text_size): the size of the text, defaults to
26
- -hp (--horizontal_padding): the padding between the text and the horizontal borders, defaults to
15
- -vp (--vertical_padding): the padding between the text and the vertical borders, defaults to
10
- -tc (--text_color): the color for the text in the format "red,green,blue", defaults to
245,245,245
- -lbc (--left_background_color): the color for the left side of the badge in the format "red,green,blue", defaults to
5,83,131
- -rbc (--right_background_color): the color for the right side of the badge in the format "red,green,blue", defaults to
85,147,199
You can use deactivate
to leave the virtual environment.
python -m venv badge-generator-venv && source ./badge-generator-venv/bin/activate && pip install -r requirements.txt
Simple usage: python badge_generator.py -lt "left text" -rt "right text"
All parameters: python badge_generator.py -lt "left text" -rt "right text" -sn "save-name" -fp "./path/to/my/font.ttf" -ts 18 -hp 10 -vp 10 -tc 255,255,255 -lbc 0,0,0 -rbc 0,0,0