Name | pil2ansi JSON |
Version |
1.0.0
JSON |
| download |
home_page | |
Summary | Convert PIL images to ANSI art |
upload_time | 2023-12-31 09:33:10 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.8 |
license | MIT License Copyright (c) 2023 Andrew Lowe Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
pil
pillow
ansi
art
image
terminal
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Pil2ANSI
Library for converting Pillow images to ANSI art
![pil2ansi3](https://github.com/lostways/pil2ansi/assets/1101232/f92f210f-5e08-4a59-831d-47d6d9aa5c59)
# Getting Started
## Installation
```
pip install pil2ansi
```
## Examples
Check out the [Convert Image Example](https://github.com/lostways/pil2ansi/blob/master/examples/convert_img.py).
```
convert_img.py [-h] [--palette {color,grayscale,grayscale_inverted,ascii}] [--width WIDTH] [--no-alpha] img_path
```
# Usage
## Convert any PIL image to ANSI art
```python
from PIL import Image
from pil2ansi import convert_img
# Open the image
img = Image.open("path/to/image.png")
# Convert to ANSI
ansi_img = convert_img(img)
# Print to screen
print(ansi_img)
```
## Palettes
There are a few palettes to choose from. To select a palette import `Palettes` and then pass the one you want into the `convert_img` function.
```python
from PIL import Image
from pil2ansi import convert_img, Palettes
# Open the image
img = Image.open("path/to/image.png")
# Convert to ANSI
ansi_img = convert_img(img, palette=Palettes.acsii)
# Print to screen
print(ansi_img)
```
The default palette is `color`. You can choose from `color`, `grayscale`, `grayscale_inverted`, and `ascii`.
## Resizing the image
By default the image will crop to the width of your terminal widow. You can change the width of the output by passing `width` to `convert_img`. This width is the number of columns you want the image to fit in your terminal window. The aspect radio of the original image will be preserved.
```python
from PIL import Image
from pil2ansi import convert_img
# Open the image
img = Image.open("path/to/image.png")
# Convert to ANSI
ansi_img = convert_img(img, width=100)
# Print to screen
print(ansi_img)
```
## Transparency
By default any part of the image with an alpha of 0 will be converted to a ` `, rendering it transparent. You can turn this off by setting `alpha` to `False` in `convert_img`.
```python
from PIL import Image
from pil2ansi import convert_img
# Open the image
img = Image.open("path/to/image.png")
# Convert to ANSI
ansi_img = convert_img(img, alpha=False)
# Print to screen
print(ansi_img)
```
# Development
Install all dependencies including dev dependencies by running `make dev`
Run tests with `make test`
Run `mypy` and `black` checks with `make lint`
Raw data
{
"_id": null,
"home_page": "",
"name": "pil2ansi",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "pil,pillow,ansi,art,image,terminal",
"author": "",
"author_email": "lostways <andrew@lostways.com>",
"download_url": "https://files.pythonhosted.org/packages/00/d1/b4e6367bd00e6d1f5edd6455ad3f61dd4eb7c52277a1a7b4d8f8bdfc085f/pil2ansi-1.0.0.tar.gz",
"platform": null,
"description": "# Pil2ANSI\nLibrary for converting Pillow images to ANSI art\n\n![pil2ansi3](https://github.com/lostways/pil2ansi/assets/1101232/f92f210f-5e08-4a59-831d-47d6d9aa5c59)\n\n# Getting Started\n\n## Installation\n```\npip install pil2ansi\n```\n\n## Examples\nCheck out the [Convert Image Example](https://github.com/lostways/pil2ansi/blob/master/examples/convert_img.py).\n```\nconvert_img.py [-h] [--palette {color,grayscale,grayscale_inverted,ascii}] [--width WIDTH] [--no-alpha] img_path\n```\n\n# Usage\n\n## Convert any PIL image to ANSI art\n```python\nfrom PIL import Image\nfrom pil2ansi import convert_img\n\n# Open the image\nimg = Image.open(\"path/to/image.png\")\n\n# Convert to ANSI\nansi_img = convert_img(img)\n\n# Print to screen\nprint(ansi_img) \n```\n\n## Palettes\nThere are a few palettes to choose from. To select a palette import `Palettes` and then pass the one you want into the `convert_img` function.\n\n```python\nfrom PIL import Image\nfrom pil2ansi import convert_img, Palettes\n\n# Open the image\nimg = Image.open(\"path/to/image.png\")\n\n# Convert to ANSI\nansi_img = convert_img(img, palette=Palettes.acsii)\n\n# Print to screen\nprint(ansi_img) \n```\n\nThe default palette is `color`. You can choose from `color`, `grayscale`, `grayscale_inverted`, and `ascii`.\n\n## Resizing the image\nBy default the image will crop to the width of your terminal widow. You can change the width of the output by passing `width` to `convert_img`. This width is the number of columns you want the image to fit in your terminal window. The aspect radio of the original image will be preserved.\n\n```python\nfrom PIL import Image\nfrom pil2ansi import convert_img\n\n# Open the image\nimg = Image.open(\"path/to/image.png\")\n\n# Convert to ANSI\nansi_img = convert_img(img, width=100)\n\n# Print to screen\nprint(ansi_img) \n```\n\n## Transparency\nBy default any part of the image with an alpha of 0 will be converted to a ` `, rendering it transparent. You can turn this off by setting `alpha` to `False` in `convert_img`.\n\n```python\nfrom PIL import Image\nfrom pil2ansi import convert_img\n\n# Open the image\nimg = Image.open(\"path/to/image.png\")\n\n# Convert to ANSI\nansi_img = convert_img(img, alpha=False)\n\n# Print to screen\nprint(ansi_img) \n```\n\n# Development\nInstall all dependencies including dev dependencies by running `make dev`\n\nRun tests with `make test`\n\nRun `mypy` and `black` checks with `make lint`\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2023 Andrew Lowe Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Convert PIL images to ANSI art",
"version": "1.0.0",
"project_urls": {
"homepage": "https://github.com/lostways/pil2ansi",
"repository": "https://github.com/lostways/pil2ansi"
},
"split_keywords": [
"pil",
"pillow",
"ansi",
"art",
"image",
"terminal"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a725ceae4606de2b7666ff401083decc04e485108e989d79e9634d25fea78e60",
"md5": "abf71d37608e63fa2fe0c7824c6dea58",
"sha256": "395bcb5db6e7c5c29df7813bf59d84521837fab8cf0471d2b04f313ea18a7fb8"
},
"downloads": -1,
"filename": "pil2ansi-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "abf71d37608e63fa2fe0c7824c6dea58",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 4999,
"upload_time": "2023-12-31T09:33:09",
"upload_time_iso_8601": "2023-12-31T09:33:09.384412Z",
"url": "https://files.pythonhosted.org/packages/a7/25/ceae4606de2b7666ff401083decc04e485108e989d79e9634d25fea78e60/pil2ansi-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "00d1b4e6367bd00e6d1f5edd6455ad3f61dd4eb7c52277a1a7b4d8f8bdfc085f",
"md5": "be366b267be56e576358a58c63673bff",
"sha256": "c4547729d7f0790559ec93685dfa343ec80960155838c605f8ee5061bce40549"
},
"downloads": -1,
"filename": "pil2ansi-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "be366b267be56e576358a58c63673bff",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 5540,
"upload_time": "2023-12-31T09:33:10",
"upload_time_iso_8601": "2023-12-31T09:33:10.928096Z",
"url": "https://files.pythonhosted.org/packages/00/d1/b4e6367bd00e6d1f5edd6455ad3f61dd4eb7c52277a1a7b4d8f8bdfc085f/pil2ansi-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-31 09:33:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lostways",
"github_project": "pil2ansi",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pil2ansi"
}