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
preprocessorslist andgeneratorclass 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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file comforticons-0.1.0.tar.gz.
File metadata
- Download URL: comforticons-0.1.0.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.1 Linux/5.10.0-22-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51ec93a0e3257a09f3f102ed958b632a8e7141e69e476298788c1070e2402b9a
|
|
| MD5 |
afbca80d4ece754918acd994206090d3
|
|
| BLAKE2b-256 |
a16e238ba1b68c0220d432ad1e89e20e767b57f39c764b181c21cd84d38b0185
|
File details
Details for the file comforticons-0.1.0-py3-none-any.whl.
File metadata
- Download URL: comforticons-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.1 Linux/5.10.0-22-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4a576046681aa306c7a2dd2b7c24124a5409657fe1f02aeb9b51e03f1229135
|
|
| MD5 |
cdd5658bf359b7640835f361dae13e17
|
|
| BLAKE2b-256 |
e36048f66ac815cc49ebd3f47c97ab04900ec4da2a696afabf119c35c18a92d6
|