GithubHelp home page GithubHelp logo

innix / github-avatar-generator Goto Github PK

View Code? Open in Web Editor NEW
24.0 2.0 3.0 14 KB

A GitHub-esque avatar image generator written in Python.

License: MIT License

Python 100.00%
python avatar generator avatar-generator image github

github-avatar-generator's Introduction

GitHub Avatar Generator

A GitHub-esque avatar image generator written in Python.

Example 1 Example 2 Example 3 Example 4 Example 5 Example 6

Installation

  1. Install the Pillow package:

    pip install Pillow
    
  2. Clone repository.

Usage

An example script is provided to demonstrate usage. The example creates a single image and saves it to a file.

python example.py <canvas_size> <block_count> <output_filename>
Parameter Summary
canvas_size The size (width and height) of the image in pixels.
block_count The number of colored blocks to use in the image.
output_filename The output image file path.

For example:

$ python example.py 420 12 avatar_01.png

License

You may use GitHub Avatar Generator under the terms of the MIT License (see LICENSE).

github-avatar-generator's People

Contributors

innix avatar nomad-vagabond avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

github-avatar-generator's Issues

The number of blocks in an avatar is sometimes wrong

Sometimes the generated avatars will have extra or missing blocks in them (e.g. 6 blocks when you asked for 5, or 5 blocks when you asked for 6).

Block placement is RNG so reproducing may take several runs. Run this a few times and eventually you will get an image with more or less than than 6 blocks:

$ python3 example.py 420 6 avatar_6_blocks.png

It is not isolated to even numbers, using an odd number 5 and the same issue will be seen:

$ python3 example.py 420 5 avatar_5_blocks.png

The problem is caused by how the generator creates vertically symmetrical images and dealing with "central" blocks that don't need an opposing block to ensure symmetry. The generator needs to be smarter about where to place blocks to ensure the avatar has the correct number of blocks but still maintains the vertical symmetry.

Infinite loop if too many blocks are requested

If you try to create an avatar with more blocks than can be fitted on the image, the avatar generator will loop forever.

Reproducible example:

$  python3 example.py 420 32 avatar_01.png

The generator should detect if too many blocks have been asked for, and raise an exception.

Use requirements.txt to manage dependencies

Instead of a list of pip commands in the README for documenting dependencies, we should use a requirements.txt file instead. The README should also be updated with new instructions on installing the library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.