ComfortIcons is an identicon generation module for different identicon/icon/gravatar/avatar flavors
Project description
Comforticons
This package is an identicon generation module for different identicon/icon/gravatar/avatar flavors.
See libravatar project and gravatar project.
This module is heavly inspired by bitverseio's PHP Identicon Generator architecture/generators and azaghal's pydenticon package (gravatar retro-like identicon generator).
Source
Requirements
- Python 3.8+
- pillow 9.5+
Installation
This module is available on pypi.org.
pip install comforticons
Features
- Modular Identicon factory architecture
preprocessors
list andgenerator
class powered identicon generation - Abstract/Interface implementations for data preprocessor and identicon generator
- Pillow 9.5+ support
- MyPy typings support
Roadmap
- ASCII-denticon generation in this package.
- SVG support for ring identicon in this package with svglib project.
- More programmer-friendly generator architecture (choose return type - PIL.Image, bytes), (direct writing to file).
- Django integration.
- Self-hosting solution for small ecosystems with FastAPI.
- Custom error classes implementation.
Usage
Interactive
python3 -m comforticons
Basic
from comforticons import Identicon
# Customize preprocessors and generator settings here
generator = Identicon()
# This will generate 120x120 with 0 padding PNG identicon
# with transparent background 5x5 pixel identicon (retro gravatar)
# using PixelGenerator and MD5Preprocessor as default
identicon = generator.generate("provide data here")
# Save to file
with open("image.png", "wb") as file:
file.write(identicon)
Advanced
from comforticons import Identicon
from comforticons.preprocessors.hash import * # *Preprocessor
from comforticons.generators.image import * # PixelGenerator
# Customize preprocessors and generator settings here
generator = Identicon(
# First, process data with md5, then with sha1
preprocessors = [MD5Preprocessor(), SHA1Preprocessor],
generator = PixelGenerator(
size = 10, # 10x10 grid
foreground_colors = ["#ffffff"], # Only use white foreground
background = "#000000", # black, non-transparent background
image_format = "png", # PNG image format
invert = True, # This will swap bg-fg colors
)
)
# Actually generate identicon
identicon = generator.generate("provide data here")
# Save to file
with open("image.png", "wb") as file:
file.write(identicon)
Examples
MD5Preprocessor
+PixelGenerator
"identicon"
SHA1Preprocessor
+PixelGenerator
"identicon"
Licensing
See LICENCE.
Also see this LICENCE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for comforticons-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4a576046681aa306c7a2dd2b7c24124a5409657fe1f02aeb9b51e03f1229135 |
|
MD5 | cdd5658bf359b7640835f361dae13e17 |
|
BLAKE2b-256 | e36048f66ac815cc49ebd3f47c97ab04900ec4da2a696afabf119c35c18a92d6 |