CustomIdenticon
Python library for generate a variety of identicons.
Features
- 3 different types of identicons
- change the final image size (size of elements, number of elements)
- change border size
- change background color
- change the transparency of elements
- change the output format (PNG, JPEG, etc.)
- choice of hashing algorithm (including your own)
Installation
pip install customidenticon
Usage
End image size = size * block_size + border * 2
import customidenticon
identicon = customidenticon.create(
"Test data",
type="pixels",
format="png",
salt="",
background="#f0f0f0",
block_visibility=140,
block_size=30,
border=25,
size=5,
hash_func=None
)
Save
import customidenticon
identicon = customidenticon.create("Test data", size=5)
with open("identicon.png", "wb") as f:
f.write(identicon)
import io
from PIL import Image
image = Image.open(io.BytesIO(identicon))
Hash algorithm
Use hashlib
for change algorithm
import hashlib
import customidenticon
identicon = customidenticon.create("Test data", hash_func=hashlib.sha3_256)
Example custom hash algorithm
import customidenticon
class MySuperHashAlgorithm:
def __init__(self, *args):
pass
def hexdigest(self):
return "0"*200
identicon = customidenticon.create("Test data", hash_func=MySuperHashAlgorithm)
Examples
import customidenticon
identicon1 = customidenticon.create("Test")
identicon1 = customidenticon.create("Test", type="pixels")
identicon2 = customidenticon.create("Test", size=6, block_size=25)
identicon4 = customidenticon.create("Test", type="layers")
identicon5 = customidenticon.create("Test", type="layers", size=8, block_size=20, border=20)
identicon6 = customidenticon.create("Test", type="block", block_visibility=100)
Result