/pyvatar

A collection of scripts to generate Github-like avatars.

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

pyvatar.py examplepyvatar.py examplepyvatar.py examplepyvatar.py examplepyvatar.py example

pyvatar

Because everything written in Python has to have py in the name.

A collection of scripts to generate Github-like avatars.

Installation

Requires Python >=3.6

git clone https://github.com/t-r-a-g-e-d-y/pyvatar.git
cd pyvatar
pip3 install -r requirements.txt

pyvatar.py

A more full featured script to generate avatars as png files.

usage: pyvatar [-h] [-r n] [-c n] [-p n] [-b n] outfile

Generate simple blocky avatars

positional arguments:
  outfile     Name of output file (no extension)

optional arguments:
  -h, --help  show this help message and exit
  -r n        Rows (Default: 7)
  -c n        Columns (Default: 7)
  -p n        Padding (Default: 1)
  -b n        Block size (Default: 48)

Examples:

./pyvatar.py -r 5 -c 5 -b 12 output

pyvatar.py example

./pyvatar.py -r 7 -c 7 -p 2 -b 12 output

pyvatar.py example

avatar.sh

A bash script for creating ansi avatars with avatar.py and converting them to images with ansimg.py Generates and prints an avatar to stdout before saving it as output.png. Run with the -i flag to preview avatars before saving.

avatar.sh example

avatar.py

Create avatars using ansi color codes and print to the terminal. A little golf attempt that spawned this project.

import random as r
a=[f'\x1b[48;5;{r.randint(0,255)}m  ','\x1b[48;5;254m  ']
b=lambda:r.choice(a)
c=a[1]*7
d='\x1b[0m\n'
e=d.join(['{d}{a}{b}{c}{b}{a}{d}'.format(a=b(),b=b(),c=b(),d=a[1]) for _ in range(5)])
print(c,e,c,sep=d,end=d)

avatar.py example

ansimg.py

Redirect the output of avatar.py to a file and use ansimg.py to create a png file out of it.

./avatar.py | ./ansimg.py output
./avatar.py > avatar.txt
./ansimg.py avatar.txt output
usage: ansimg.py [-h] infile outfile [block_size]

positional arguments:
  infile      File generated by avatar.py
  outfile     Name of output file (no extension)
  block_size  Default: 48

optional arguments:
  -h, --help  show this help message and exit