Skip to main content

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

Link to source.

Requirements

  • Python 3.8+
    • pillow 9.5+

Installation

This module is available on pypi.org.

Newest PyPi version

pip install comforticons

Features

  • Modular Identicon factory architecture

    preprocessors list and generator 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"
identicon

SHA1Preprocessor + PixelGenerator
"identicon"
identicon

Licensing

See LICENCE.

Also see this LICENCE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

comforticons-0.1.0.tar.gz (9.3 kB view hashes)

Uploaded Source

Built Distribution

comforticons-0.1.0-py3-none-any.whl (10.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page