pyavatar


Namepyavatar JSON
Version 0.1.5 PyPI version JSON
download
home_pagehttps://github.com/smallwat3r/pyavatar
SummaryGenerate simple user avatars from an input string.
upload_time2023-10-24 17:56:32
maintainer
docs_urlNone
authorMatthieu Petiteau
requires_python>=3.10
licenseMIT
keywords avatar
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h3 align="center">pyavatar</h3>
<p align="center">Create default user avatars from a given string</p>

<p align="center">
  <img src="https://raw.githubusercontent.com/smallwat3r/pyavatar/master/ext/1.png" />
  <img src="https://raw.githubusercontent.com/smallwat3r/pyavatar/master/ext/2.png" />
  <img src="https://raw.githubusercontent.com/smallwat3r/pyavatar/master/ext/3.png" />
</p>

<p align="center">
  <a href="https://codecov.io/gh/smallwat3r/pyavatar" rel="nofollow"><img src="https://codecov.io/gh/smallwat3r/pyavatar/branch/master/graph/badge.svg" style="max-width:100%;"></a>
  <a href="https://pypi.org/project/pyavatar" rel="nofollow"><img src="https://img.shields.io/pypi/wheel/pyavatar.svg" style="max-width:100%;"></a>
  <a href="https://github.com/smallwat3r/pyavatar/blob/master/LICENSE" rel="nofollow"><img src="https://img.shields.io/badge/License-MIT-green.svg" style="max-width:100%;"></a>
</p>

This package creates simple user avatars that can be used in web-applications.  
Avatars are generated from the first letter of a given string input.  

### Installation

Pyavatar is on Pypi so all you need is:
```
pip install pyavatar
```

### Usage

Generate an avatar  
```python
>>> from pyavatar import PyAvatar
>>>
>>> avatar = PyAvatar("smallwat3r", size=250)  # use a specific size
>>> avatar = PyAvatar("smallwat3r", capitalize=False)  # without capitalization
>>> avatar = PyAvatar("smallwat3r", color=(40, 176, 200))  # use a specific color
>>> avatar = PyAvatar("smallwat3r", fontpath="/Users/me/fonts/myfont.ttf")  # use a specific font
```

Change the avatar color
```python
>>> avatar.color
(191, 91, 81)
>>> avatar.change_color()  # random color
>>> avatar.color
(203, 22, 126) 
>>> avatar.change_color("#28b0c8")  # using an hex color code
>>> avatar.color
'#28b0c8'
```

Save the avatar as a base64 image
```python
>>> image = avatar.base64_image("jpeg")
'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBg ...'
```

You can then render it in an html tag with Jinja or another template engine
```html
<img src="{{ image }}" alt="My avatar" />
```

Or save it as a bytes array
```python
>>> avatar.stream("png")
b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\xfa\x00\x00 ...'
```

Or save it as a file locally
```python
>>> import os
>>> avatar.save(f"{os.getcwd()}/me.png")
```

### Development

#### Requirements

Make sure you're using a version of Python >= 3.10

- Create a virtual environment and install the dependencies
  ```
  make venv deps
  ```

#### Sanity checks

- Unit tests
  ```
  make tests
  ```

- Mypy 
  ```
  make mypy
  ```

- Ruff 
  ```
  make ruff
  ```

- Run all the above
  ```
  make ci
  ```

#### Code formatting

 We're using [YAPF](https://github.com/google/yapf) to format the code
```
make yapf
```

#### Release to Pypi

```
make release
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/smallwat3r/pyavatar",
    "name": "pyavatar",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "avatar",
    "author": "Matthieu Petiteau",
    "author_email": "mpetiteau.pro@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c0/4c/8a6d9c6d3dd9e163abdba663ad3f6ca02e33a53a91a9e6faa9668a38e4e7/pyavatar-0.1.5.tar.gz",
    "platform": null,
    "description": "<h3 align=\"center\">pyavatar</h3>\n<p align=\"center\">Create default user avatars from a given string</p>\n\n<p align=\"center\">\n  <img src=\"https://raw.githubusercontent.com/smallwat3r/pyavatar/master/ext/1.png\" />\n  <img src=\"https://raw.githubusercontent.com/smallwat3r/pyavatar/master/ext/2.png\" />\n  <img src=\"https://raw.githubusercontent.com/smallwat3r/pyavatar/master/ext/3.png\" />\n</p>\n\n<p align=\"center\">\n  <a href=\"https://codecov.io/gh/smallwat3r/pyavatar\" rel=\"nofollow\"><img src=\"https://codecov.io/gh/smallwat3r/pyavatar/branch/master/graph/badge.svg\" style=\"max-width:100%;\"></a>\n  <a href=\"https://pypi.org/project/pyavatar\" rel=\"nofollow\"><img src=\"https://img.shields.io/pypi/wheel/pyavatar.svg\" style=\"max-width:100%;\"></a>\n  <a href=\"https://github.com/smallwat3r/pyavatar/blob/master/LICENSE\" rel=\"nofollow\"><img src=\"https://img.shields.io/badge/License-MIT-green.svg\" style=\"max-width:100%;\"></a>\n</p>\n\nThis package creates simple user avatars that can be used in web-applications.  \nAvatars are generated from the first letter of a given string input.  \n\n### Installation\n\nPyavatar is on Pypi so all you need is:\n```\npip install pyavatar\n```\n\n### Usage\n\nGenerate an avatar  \n```python\n>>> from pyavatar import PyAvatar\n>>>\n>>> avatar = PyAvatar(\"smallwat3r\", size=250)  # use a specific size\n>>> avatar = PyAvatar(\"smallwat3r\", capitalize=False)  # without capitalization\n>>> avatar = PyAvatar(\"smallwat3r\", color=(40, 176, 200))  # use a specific color\n>>> avatar = PyAvatar(\"smallwat3r\", fontpath=\"/Users/me/fonts/myfont.ttf\")  # use a specific font\n```\n\nChange the avatar color\n```python\n>>> avatar.color\n(191, 91, 81)\n>>> avatar.change_color()  # random color\n>>> avatar.color\n(203, 22, 126) \n>>> avatar.change_color(\"#28b0c8\")  # using an hex color code\n>>> avatar.color\n'#28b0c8'\n```\n\nSave the avatar as a base64 image\n```python\n>>> image = avatar.base64_image(\"jpeg\")\n'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBg ...'\n```\n\nYou can then render it in an html tag with Jinja or another template engine\n```html\n<img src=\"{{ image }}\" alt=\"My avatar\" />\n```\n\nOr save it as a bytes array\n```python\n>>> avatar.stream(\"png\")\nb'\\x89PNG\\r\\n\\x1a\\n\\x00\\x00\\x00\\rIHDR\\x00\\x00\\x00\\xfa\\x00\\x00 ...'\n```\n\nOr save it as a file locally\n```python\n>>> import os\n>>> avatar.save(f\"{os.getcwd()}/me.png\")\n```\n\n### Development\n\n#### Requirements\n\nMake sure you're using a version of Python >= 3.10\n\n- Create a virtual environment and install the dependencies\n  ```\n  make venv deps\n  ```\n\n#### Sanity checks\n\n- Unit tests\n  ```\n  make tests\n  ```\n\n- Mypy \n  ```\n  make mypy\n  ```\n\n- Ruff \n  ```\n  make ruff\n  ```\n\n- Run all the above\n  ```\n  make ci\n  ```\n\n#### Code formatting\n\n We're using [YAPF](https://github.com/google/yapf) to format the code\n```\nmake yapf\n```\n\n#### Release to Pypi\n\n```\nmake release\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Generate simple user avatars from an input string.",
    "version": "0.1.5",
    "project_urls": {
        "Homepage": "https://github.com/smallwat3r/pyavatar"
    },
    "split_keywords": [
        "avatar"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b3a57d67b943a4ae96d3e5bbad3c28bb104ef15d305b240f6c5615b23d2a5932",
                "md5": "a17ab44f948a481e385d2ad931fc2bfc",
                "sha256": "4fa1fb50946233830eeb5c71044de3aba4d92c6f8dab71941187114e01e4d7bc"
            },
            "downloads": -1,
            "filename": "pyavatar-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a17ab44f948a481e385d2ad931fc2bfc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 68445,
            "upload_time": "2023-10-24T17:56:30",
            "upload_time_iso_8601": "2023-10-24T17:56:30.369549Z",
            "url": "https://files.pythonhosted.org/packages/b3/a5/7d67b943a4ae96d3e5bbad3c28bb104ef15d305b240f6c5615b23d2a5932/pyavatar-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c04c8a6d9c6d3dd9e163abdba663ad3f6ca02e33a53a91a9e6faa9668a38e4e7",
                "md5": "94d82ab67526a50667732eca8c5d2109",
                "sha256": "161fca9d5530272743b51d1e7b5bb02a8afd208175b9a759ae1625cbad283fb3"
            },
            "downloads": -1,
            "filename": "pyavatar-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "94d82ab67526a50667732eca8c5d2109",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 71924,
            "upload_time": "2023-10-24T17:56:32",
            "upload_time_iso_8601": "2023-10-24T17:56:32.461892Z",
            "url": "https://files.pythonhosted.org/packages/c0/4c/8a6d9c6d3dd9e163abdba663ad3f6ca02e33a53a91a9e6faa9668a38e4e7/pyavatar-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-24 17:56:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "smallwat3r",
    "github_project": "pyavatar",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pyavatar"
}
        
Elapsed time: 0.12595s