ripix


Nameripix JSON
Version 2.5.0 PyPI version JSON
download
home_pagehttps://github.com/romanin-rf/ripix
SummaryA Rich-compatible library for writing pixel images and ASCII art to the terminal.
upload_time2023-12-15 19:08:24
maintainer
docs_urlNone
authorDarren Burns
requires_python>=3.7,<3.12
license
keywords ripix rich textual image pixels ascii-art rich_pixels
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Ripix

A Rich-compatible library for writing pixel images and other colourful grids to the
terminal.

<p align="center">
<img width="700" src="https://user-images.githubusercontent.com/5740731/200676207-8e9c9465-628b-40de-ba0b-410612f2bd7c.svg" />
</p>

## Installation

Get `ripix` from PyPI.

```
pip install ripix
```

## Basic Usage

### Images

#### Image from a file

You can load an image file from a path using `from_image_path`:

```python
from ripix import Pixels
from rich.console import Console

console = Console()
pixels = Pixels.from_image_path("pokemon/bulbasaur.png")
console.print(pixels)
```

#### Pillow image object

You can create a PIL image object yourself and pass it in to `from_image`.

```python
from ripix import Pixels
from rich.console import Console
from PIL import Image

console = Console()

with Image.open("path/to/image.png") as image:
    pixels = Pixels.from_image(image)

console.print(pixels)
```

Using this approach means you can modify your PIL `Image` beforehard.

#### ASCII Art

You can quickly build shapes using a tool like [asciiflow](https://asciiflow.com), and
apply styles the ASCII characters. This provides a quick way of sketching out shapes.

```python
from ripix import Pixels
from rich.console import Console

console = Console()

# Draw your shapes using any character you want
grid = """\
     xx   xx
     ox   ox
     Ox   Ox
xx             xx
xxxxxxxxxxxxxxxxx
"""

# Map characters to different characters/styles
mapping = {
    "x": Segment(" ", Style.parse("yellow on yellow")),
    "o": Segment(" ", Style.parse("on white")),
    "O": Segment(" ", Style.parse("on blue")),
}

pixels = Pixels.from_ascii(grid, mapping)
console.print(pixels)
```

### Using with Textual

`Pixels` can be integrated into [Textual](https://github.com/Textualize/textual)
applications just like any other Rich renderable.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/romanin-rf/ripix",
    "name": "ripix",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<3.12",
    "maintainer_email": "",
    "keywords": "ripix,rich,textual,image,pixels,ascii-art,rich_pixels",
    "author": "Darren Burns",
    "author_email": "darrenb900@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/77/c4/30bb1cab626efd47967eb28614566ccd75286b23b0da463e3b4dd2299bdb/ripix-2.5.0.tar.gz",
    "platform": null,
    "description": "# Ripix\n\nA Rich-compatible library for writing pixel images and other colourful grids to the\nterminal.\n\n<p align=\"center\">\n<img width=\"700\" src=\"https://user-images.githubusercontent.com/5740731/200676207-8e9c9465-628b-40de-ba0b-410612f2bd7c.svg\" />\n</p>\n\n## Installation\n\nGet `ripix` from PyPI.\n\n```\npip install ripix\n```\n\n## Basic Usage\n\n### Images\n\n#### Image from a file\n\nYou can load an image file from a path using `from_image_path`:\n\n```python\nfrom ripix import Pixels\nfrom rich.console import Console\n\nconsole = Console()\npixels = Pixels.from_image_path(\"pokemon/bulbasaur.png\")\nconsole.print(pixels)\n```\n\n#### Pillow image object\n\nYou can create a PIL image object yourself and pass it in to `from_image`.\n\n```python\nfrom ripix import Pixels\nfrom rich.console import Console\nfrom PIL import Image\n\nconsole = Console()\n\nwith Image.open(\"path/to/image.png\") as image:\n    pixels = Pixels.from_image(image)\n\nconsole.print(pixels)\n```\n\nUsing this approach means you can modify your PIL `Image` beforehard.\n\n#### ASCII Art\n\nYou can quickly build shapes using a tool like [asciiflow](https://asciiflow.com), and\napply styles the ASCII characters. This provides a quick way of sketching out shapes.\n\n```python\nfrom ripix import Pixels\nfrom rich.console import Console\n\nconsole = Console()\n\n# Draw your shapes using any character you want\ngrid = \"\"\"\\\n     xx   xx\n     ox   ox\n     Ox   Ox\nxx             xx\nxxxxxxxxxxxxxxxxx\n\"\"\"\n\n# Map characters to different characters/styles\nmapping = {\n    \"x\": Segment(\" \", Style.parse(\"yellow on yellow\")),\n    \"o\": Segment(\" \", Style.parse(\"on white\")),\n    \"O\": Segment(\" \", Style.parse(\"on blue\")),\n}\n\npixels = Pixels.from_ascii(grid, mapping)\nconsole.print(pixels)\n```\n\n### Using with Textual\n\n`Pixels` can be integrated into [Textual](https://github.com/Textualize/textual)\napplications just like any other Rich renderable.\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Rich-compatible library for writing pixel images and ASCII art to the terminal.",
    "version": "2.5.0",
    "project_urls": {
        "Homepage": "https://github.com/romanin-rf/ripix",
        "Repository": "https://github.com/romanin-rf/ripix"
    },
    "split_keywords": [
        "ripix",
        "rich",
        "textual",
        "image",
        "pixels",
        "ascii-art",
        "rich_pixels"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ac95154344ae9e65fe78cdbf0e2cc064db28f3b86ced1f257596667d20023372",
                "md5": "7a4a8df7a564d62db7410191cd7b4d3b",
                "sha256": "f62b4eba715d935f1717b1323723e94406b792c8d9757ef782277a6010e0af6f"
            },
            "downloads": -1,
            "filename": "ripix-2.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7a4a8df7a564d62db7410191cd7b4d3b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<3.12",
            "size": 3639,
            "upload_time": "2023-12-15T19:08:23",
            "upload_time_iso_8601": "2023-12-15T19:08:23.304407Z",
            "url": "https://files.pythonhosted.org/packages/ac/95/154344ae9e65fe78cdbf0e2cc064db28f3b86ced1f257596667d20023372/ripix-2.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "77c430bb1cab626efd47967eb28614566ccd75286b23b0da463e3b4dd2299bdb",
                "md5": "cdd1fe2787b84c135d5104fc002add90",
                "sha256": "8693f499107687f7d7beb0be0c901bb4ab274460a76ccdda154d9018538ad011"
            },
            "downloads": -1,
            "filename": "ripix-2.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "cdd1fe2787b84c135d5104fc002add90",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<3.12",
            "size": 3417,
            "upload_time": "2023-12-15T19:08:24",
            "upload_time_iso_8601": "2023-12-15T19:08:24.707461Z",
            "url": "https://files.pythonhosted.org/packages/77/c4/30bb1cab626efd47967eb28614566ccd75286b23b0da463e3b4dd2299bdb/ripix-2.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-15 19:08:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "romanin-rf",
    "github_project": "ripix",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ripix"
}
        
Elapsed time: 2.87203s