Python avatar generator for absolute nerds

Related tags

Image Processingpagan
Overview

pagan

Welcome to the Python Avatar Generator for Absolute Nerds.

Current version: 0.4.3

View the change history here.

Remember those good old days when your imagination was a big part of the computer gaming experience? Hardware limitations forced you to fill the void left by poorly pixelated images. Pagan brings back those nostalgic feelings by generating identicons in an old-school style inspired by retro roleplaying adventure games.

Pagan hashes input strings to generate unique avatar images intended for use as profile pictures in web applications. These images can be used to replace default user images for new accounts, or to enhance comment sections by visually representing a user's IP address or username.

Pagan is currently under development. It can perform the following functions:

  • Generate identicons with unique colors and gear based on any input string.
  • Use multiple hash functions from within Python's hashlib.
  • Create avatar images to fit a specific resolution.
  • Remap 16x16 generated pixelmaps to a required image size.
  • Expand generated pagans by adding new weapons or gear.

Enjoy the nostalgia!

Some example avatars hashed with SHA512:

Input Avatar
pagan pagan
python python
avatar avatar
github github
retro retro
piece of cake piece of cake
hash me if you can hash me if you can

Installation:

To install Pagan, first clone this repository:

>> git clone https://github.com/daboth/pagan.git

Then, enter this command at the terminal to manually install Pagan:

>> python setup.py install

Alternatively, use this command to install pagan via pip:

>> pip install pagan

Python usage example:

# Import the pagan module.
import pagan

# Acquire an arbitrary string.
inpt = 'pagan'

# Use pagan to generate an avatar object based on an input string.
# Optional: You may specify which hash function Pagan should use.
# The functions are available as constants.
# Default: MD5.
img = pagan.Avatar(inpt, pagan.SHA512)

# Open the avatar image in an
# external image viewer.
img.show()

# Set an output path and a file name.
# You don't need to specify a file ending.
# Choose a path depending on your OS.
outpath = 'output/'
filename = inpt

# Saves the avatar image as a .png file
# by omitting the path and name. The
# file endings will be generated automatically.
img.save(outpath, filename)

# You can change the avatar input and
# hash function anytime.
img.change('new input', pagan.SHA256)

Command Line Interface

The pagan command line interface can be used to generate avatars without needing to write a python script:

>> pagan [-h] [--show] [--output OUTPUT] [--hash HASH] input [input ...]

For example, typing

>> pagan hello

will generate an avatar from the string 'hello' and save it in the current working directory.

For more information, execute Pagan using the -h help parameter:

>> pagan -h

Webserver

A demo of Pagan can be run in a webserver application. To access the Pagan demo, execute the following instructions from the webserver directory:

>> cd /tools/webserver/
>> python webserver.py

Beware: This demo of Pagan will fill your temporary directory with generated image files. Do not run it in production!

The webserver will serve from localhost port 8080. Open this adress in your browser window:

http://127.0.0.1:8080/

Supported Hashes

Hash Constant
md5 pagan.MD5
sha1 pagan.SHA1
sha224 pagan.SHA224
sha256 pagan.SHA256
sha384 pagan.SHA384
sha512 pagan.SHA512

Testing

To test Pagan, you must install either the pytest or tox Python modules. Configure tox.ini to test different Python versions.

Docker

To use pagan within Docker, you must build the Docker image with:

>> docker build -t pagan .

Then, run docker image

>> docker run -d -p 8080:8080 -t pagan

The webserver inside Docker will serve from localhost port 8080. Open this adress in your browser window:

http://127.0.0.1:8080/

If you want to use PAGAN CLI, you just have to look for the IP Adress of the Docker container and then connect through ssh with user: pagan and pass: pagan, like this:

>> ssh -X [email protected]

Using py.test

>> pip install pytest
>> pytest

Using tox

>> pip install tox
>> tox
Comments
  • Enable installation with setuptools >=58

    Enable installation with setuptools >=58

    setuptools v58.0.0 removed support for use_2to3 during builds. This patch simply adds a pyproject.toml that pins setuptools to a version smaller than 58.0.0. It's a bare minimum band-aid to get pagan to install with a new version of setuptools.

    opened by wjv 11
  • Fixed use_2to_3

    Fixed use_2to_3

    Switching flag to false resolves pip installation erros and running python setup. At least in python 3.9. Errors:

    #setup
    python .\setup.py
    error in pagan setup command: use_2to3 is invalid.
    
    #pip
    pip install pagan
    Collecting pagan
      Using cached pagan-0.4.3.tar.gz (21 kB)
      Preparing metadata (setup.py) ... error
      error: subprocess-exited-with-error
    
      × python setup.py egg_info did not run successfully.
      │ exit code: 1
      ╰─> [1 lines of output]
          error in pagan setup command: use_2to3 is invalid.
          [end of output]
    
      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: metadata-generation-failed
    
    × Encountered error while generating package metadata.
    ╰─> See above for output.
    
    note: This is an issue with the package mentioned above, not pip.
    hint: See above for details.
    

    Think leaving this as default config is neeeded since python2 is deprecated

    opened by Intellbg 2
  • Provide Docker Images [DONE]

    Provide Docker Images [DONE]

    The are currently no public Docker images available. An image would be useful for easy deployment of the webserver (in production and for testing purposes) as well as a convenient CLI without the need to install external dependencies.

    opened by kiview 1
  • docs: Fix a few typos

    docs: Fix a few typos

    There are small typos in:

    • README.md
    • pagan/hashgrinder.py
    • pagan/pgnreader.py

    Fixes:

    • Should read address rather than adress.
    • Should read variations rather than variatons.
    • Should read tuples rather than tupels.
    • Should read tuple rather than tupel.
    • Should read separate rather than seperate.

    Semi-automated pull request generated by https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

    opened by timgates42 0
  • Update setup.py

    Update setup.py

    removed use_2to3=True in setup.py installation results in error related to an update in setuptools

    v58.0.2 06 Sep 2021 Misc #2769: Build now fails fast when use_2to3 is supplied.

    i cloed it better to just fix setuptools version

    opened by ZakiOro 0
  • Rework on templates

    Rework on templates

    The templates to generate each figure are purely textbase, to enable everyone to contribute on this without any affinity or knowledge about programming. Do you think the system needs a rework? From my point of view, as i grew as a software/scientific guy, the currently implemented systems seems a bit outdated. Would appreciate everyones thought on that. This issue, by far however, is placed super late in my backlog, so take your time.

    opened by daboth 1
  • Increase virtual resolution to add more detail

    Increase virtual resolution to add more detail

    Hello again. This is a big one. I really liked the original idea to limit myself on the overall virtual pixel output. What are your thoughts about increasing the size to generate more detailed figures and maybe even add background generation in this process. I'm aware that it would have a mayor impact on the idea, so i'd really like to read your thoughts on this one.

    opened by daboth 1
  • Support for cropped circles

    Support for cropped circles

    Hello everyone. I lack the power to describe this topic, but you know the trend where every app takes your image and crops a circle from it? Yes, this looks bad with the native pagan output and will surely take some workaround if you consider pagan as a tool in an automated process. So i'm open for suggestions here. The first thing i could think of would be to just generate a bigger "outer space" around the actual image, but i'd like to reach out for a better, more "standalone too" option to cover this case.

    opened by daboth 0
  • Colorful Backgrounds

    Colorful Backgrounds

    Hello to all supporters and a very special "Thank you" for using pagan in your projects. I never thought this one would draw such attention and i'm overwhelmed by the positive feedback it got. I got back into programming a while ago, so let's start out with some ideas. The first one being backgrounds. It always bothered me, that the backgrounds are plain as can be. Instead i started looking for some mechanics to generate some overall color metric from the generated virtual pixels to add a background in complementary colors to the mix. The challenge is to generate a background that does not only avoid to obfuscate the drawn figures, but actually highlight them, so that every result from pagan is a good and usable complete image.

    opened by daboth 1
  • Removed webserver, minor changes

    Removed webserver, minor changes

    • remove pagan webserver stuff from repo and move stuff to new repo
    • fix pylint complains about docstring format in pagan
    • pagan console version saves avatar to file, when none is specified it is saved to "input" "$ pagan /etc/password " would save avatar for input /etc/password to file /etc/password.png changed to only allow letters and digits, replace other characters to "-" "$ pagan /etc/password" saves to -etc-password.png
    • pagan console, add --noshow option, to supress opening of viewer
    • add test case for console pagan, add more tests
    opened by xnor 1
Releases(0.4.4)
Owner
David Bothe
David Bothe
cmdpxl: a totally practical command-line image editor

cmdpxl: a totally practical command-line image editor Features cmdpxl has many exciting functionalities, including Editing pixels one at a time! Savin

Jieruei Chang 475 Dec 23, 2022
Png2Jpg tool will help you convert from png image format to jpg images format.

PNG 2 JPG All codes assume running from root directory. Please update the sys path at the beginning of the codes before running. Over View Png2Jpg too

Nguyễn Trường Lâu 2 Dec 27, 2021
Qt based ebook reader

Qt based ebook reader Currently supports: pdf epub djvu fb2 mobi azw / azw3 / azw4 cbr / cbz md Contribute Paypal Bitcoin: 17jaxj26vFJNqQ2hEVerbBV5fpT

1.4k Dec 26, 2022
SGTL - Spectral Graph Theory Library

SGTL - Spectral Graph Theory Library SGTL is a python library of spectral graph theory methods. The library is still very new and so there are many fe

Peter Macgregor 6 Oct 01, 2022
QR fixer part is standalone but for image to FQR conversion

f-qr-fixer QR fixer part is standalone but for image to FQR conversion it requires Pillow (can be installed with easy_install), qrtools (on ubuntu the

2 Nov 22, 2022
Javascript image annotation tool based on image segmentation.

JS Segment Annotator Javascript image annotation tool based on image segmentation. Label image regions with mouse. Written in vanilla Javascript, with

Kota Yamaguchi 513 Nov 15, 2022
A Python package implementing various HDRI / Radiance image processing algorithms.

Colour - HDRI A Python package implementing various HDRI / Radiance image processing algorithms. It is open source and freely available under the New

colour-science 111 Dec 06, 2022
Tweet2Image - Convert tweets to Instagram-friendly images.

Convert tweets to Instagram-friendly images. How to use If you want to use this repository as a submodule, don't forget to put the fonts d

Janu Lingeswaran 1 Mar 11, 2022
Generate different types of random avatars.

avatar-generator Generate different types of random avatars. Requirements Python3 pytorch=1.6 cv2=3.4 tqdm 1. Github-like avatars python generate_gi

Ming 11 Apr 02, 2022
An automated Comic Book downloader (cbr/cbz) for use with SABnzbd, NZBGet and torrents

Mylar Note that feature development has stopped as we have moved to Mylar3. EOL for this project is the end of 2020 and will no longer be supported. T

979 Dec 13, 2022
HyperBlend is a new type of hyperspectral image simulator based on Blender.

HyperBlend version 0.1.0 This is the HyperBlend leaf spectra simulator developed in Spectral Laboratory of University of Jyväskylä. You can use and mo

SILMAE 2 Jun 20, 2022
This is an app that allows users to upload photos and display and store the photos in a file until the user deletes them.

Qt Photo App This is an app that allows users to upload photos and display and store the photos in a file until the user deletes them. Setup python3 -

Kathy Yang 5 Jan 22, 2022
A functional and efficient python implementation of the 3D version of Maxwell's equations

py-maxwell-fdfd Solving Maxwell's equations via A python implementation of the 3D curl-curl E-field equations. This code contains additional work to e

Nathan Zhao 12 Dec 11, 2022
ProsePainter combines direct digital painting with real-time guided machine-learning based image optimization.

ProsePainter Create images by painting with words. ProsePainter combines direct digital painting with real-time guided machine-learning based image op

Morphogen 276 Dec 17, 2022
a lite weight photo editor written in python for day to day photo editing!

GNU-PhotoShop A lite weight Photo editing Program (currently CLI only) written in python3 for day to day photo editing. Disclaimer : Currently we don'

Kunal Sharma 5 May 30, 2022
Png-to-stl - Converts PNG and text to SVG, and then extrudes that based on parameters

have ansible installed locally run ansible-playbook setup_application.yml this sets up directories, installs system packages, and sets up python envir

1 Jan 03, 2022
利用近邻法的弱点实现图片缩小后变成另一张图

这是我一个视频的配套代码。 视频是:利用近邻法的弱点实现图片缩小后变成另一张图 https://www.bilibili.com/video/BV1Lf4y1r7dZ 配套代码中,仅generate.py是核心文件,其余的图片神马的,都是赠品。 这个核心文件利用了近邻法缩放的弱点,可以将图a的像素按

偶尔有点小迷糊 182 Dec 19, 2022
Anaglyph 3D Converter - A python script that adds a 3D anaglyph style effect to an image using the Pillow image processing package.

Anaglyph 3D Converter - A python script that adds a 3D anaglyph style effect to an image using the Pillow image processing package.

Kizdude 2 Jan 22, 2022
Computer art based on joining transparent images

Computer Art There is no must in art because art is free. Introduction The following tutorial exaplains how to generate computer art based on a series

Computer Art 12 Jul 30, 2022
A sketch like(?) effect for images

lineArt A sketch like(?) effect for images How to run main.py [filename] [option {1,2}] option 1 retains colour option 2 gives gray image #results ori

1 Oct 28, 2021