| 1 |
Metadata-Version: 2.1 |
| 2 |
Name: customidenticon |
| 3 |
Version: 0.1.5 |
| 4 |
Summary: Python3 library for generate a variety of identicons |
| 5 |
Home-page: https://github.com/lexserest/customidenticon |
| 6 |
Author: LexSerest |
| 7 |
Author-email: [email protected] |
| 8 |
Maintainer: LexSerest |
| 9 |
Maintainer-email: [email protected] |
| 10 |
License: MIT |
| 11 |
Description: # CustomIdenticon |
| 12 |
|
| 13 |
 |
| 14 |
|
| 15 |
Python library for generate a variety of identicons. |
| 16 |
|
| 17 |
[](https://travis-ci.org/LexSerest/customidenticon) |
| 18 |
|
| 19 |
## Features |
| 20 |
|
| 21 |
- 3 different types of identicons |
| 22 |
- change the final image size (size of elements, number of elements) |
| 23 |
- change border size |
| 24 |
- change background color |
| 25 |
- change the transparency of elements |
| 26 |
- change the output format (PNG, JPEG, etc.) |
| 27 |
- choice of hashing algorithm (including your own) |
| 28 |
|
| 29 |
|
| 30 |
## Installation |
| 31 |
|
| 32 |
`pip install customidenticon` |
| 33 |
|
| 34 |
## Usage |
| 35 |
End image size = size * block_size + border * 2 |
| 36 |
```python |
| 37 |
import customidenticon |
| 38 |
identicon = customidenticon.create( |
| 39 |
"Test data", # Data |
| 40 |
type="pixels", # Type of algorithm (pixels, blocks or layers) |
| 41 |
format="png", # Output format |
| 42 |
salt="", # salt for more variants |
| 43 |
background="#f0f0f0", # background color |
| 44 |
block_visibility=140, # transparency of elements in the image (0-255) |
| 45 |
block_size=30, # size of elements (px) |
| 46 |
border=25, # border (px) |
| 47 |
size=5, # number of elements |
| 48 |
hash_func=None # hash function (auto) |
| 49 |
) |
| 50 |
|
| 51 |
``` |
| 52 |
|
| 53 |
### Save |
| 54 |
```python |
| 55 |
import customidenticon |
| 56 |
identicon = customidenticon.create("Test data", size=5) |
| 57 |
# identicon = b"\x89PNG\r\n\x1a\n\x00\x00\x00..." |
| 58 |
|
| 59 |
# save to file |
| 60 |
with open("identicon.png", "wb") as f: |
| 61 |
f.write(identicon) |
| 62 |
|
| 63 |
# to image |
| 64 |
import io |
| 65 |
from PIL import Image |
| 66 |
image = Image.open(io.BytesIO(identicon)) |
| 67 |
``` |
| 68 |
|
| 69 |
## Hash algorithm |
| 70 |
Use `hashlib` for change algorithm |
| 71 |
```python |
| 72 |
import hashlib |
| 73 |
import customidenticon |
| 74 |
identicon = customidenticon.create("Test data", hash_func=hashlib.sha3_256) |
| 75 |
``` |
| 76 |
Example custom hash algorithm |
| 77 |
```python |
| 78 |
import customidenticon |
| 79 |
class MySuperHashAlgorithm: |
| 80 |
def __init__(self, *args): |
| 81 |
pass |
| 82 |
def hexdigest(self): |
| 83 |
return "0"*200 |
| 84 |
|
| 85 |
identicon = customidenticon.create("Test data", hash_func=MySuperHashAlgorithm) |
| 86 |
``` |
| 87 |
|
| 88 |
## Examples |
| 89 |
|
| 90 |
```python |
| 91 |
import customidenticon |
| 92 |
# Create github-like (5x5) |
| 93 |
identicon1 = customidenticon.create("Test") # 200x200px (default for all) |
| 94 |
# or |
| 95 |
identicon1 = customidenticon.create("Test", type="pixels") |
| 96 |
|
| 97 |
# Create "pixels" type (6x6) |
| 98 |
# End image size 200x200px (6 * 25 + 25 * 2) |
| 99 |
identicon2 = customidenticon.create("Test", size=6, block_size=25) |
| 100 |
|
| 101 |
# Create "layers" type (3 layer) |
| 102 |
# End image size 200x200px (default size = 3 and block_size = 50) |
| 103 |
identicon4 = customidenticon.create("Test", type="layers") |
| 104 |
|
| 105 |
# Create "layers" type (8 layer) |
| 106 |
# End image size 200x200px (8 * 20 + 20 * 2) |
| 107 |
identicon5 = customidenticon.create("Test", type="layers", size=8, block_size=20, border=20) |
| 108 |
|
| 109 |
# Create "blocks" type (3x3) (200x200px) |
| 110 |
identicon6 = customidenticon.create("Test", type="block", block_visibility=100) |
| 111 |
``` |
| 112 |
|
| 113 |
|
| 114 |
##### Result |
| 115 |
 |
| 116 |
|
| 117 |
Keywords: identicon image avatar profile github custom customidenticon |
| 118 |
Platform: UNKNOWN |
| 119 |
Description-Content-Type: text/markdown |