Skip to main content

No project description provided

Project description

Convert image/gif/video to ascii art. If you inputs have plenty of frames, you can specify --fast to use torch accelerating the peocess.

Screen Shot

example example1

Experimental feature

Now you can add --alpha to generate neovim highlight definitions, for example:

img2art xxx.png --scale 0.1 --threshold 120 --save-raw ./xxx.txt --alpha

It will generate code definitions in target file which consists of three parts:

  1. Code of setting neovim highlight like vim.api.nvim_set_hl(0, "I2A0", { fg="#2f3651" }), which will be plenty of lines.
  2. The mapping between every pixels and highlights.
  3. The ascii art which was warppered by [[ ]] every single line.

Copy the contents of generated file and set properly in your config of alpha-nvim, it will be:

example2

If img2art generate too much lines, you can specify --quant n to reduce the color level of input image. n is a positive integer which should be smaller than 256.

img2art xxx.png --scale 0.1 --threshold 120 --save-raw ./xxx.txt --alpha --quant 16

Installation

requirements: typer[all], opencv-python, numpy

pip install img2art

Usage

img2art --help

result:

 Usage: img2art [OPTIONS] SOURCE

╭─ Arguments ─────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *    source      TEXT  Path to image [default: None] [required]                                                     │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --with-color    --no-with-color                                  Whether use color. If you specify alpha,           │
│                                                                  with-color will be forcely set to True.            │
│                                                                  [default: no-with-color]                           │
│ --scale                            FLOAT                         Scale applied to image [default: 1.0]              │
│ --threshold                        INTEGER                       Threshold applied to image, default to OSTU        │
│                                                                  [default: -1]                                      │
│ --save-raw                         TEXT                          Whether to save the raw data [default: None]       │
│ --bg-color                         <INTEGER INTEGER INTEGER>...  Backgound color, (-1, -1, -1) for none             │
│                                                                  [default: -1, -1, -1]                              │
│ --fast          --no-fast                                        Whether use torch to accelerate when you inputs    │
│                                                                  have plenty of frames.                             │
│                                                                  [default: no-fast]                                 │
│ --chunk-size                       INTEGER                       Chunk size of Videos or Gifs when using torch.     │
│                                                                  [default: 1024]                                    │
│ --alpha         --no-alpha                                       Whether generating lua code for alpha-nvim.        │
│                                                                  [default: no-alpha]                                │
│ --quant                            INTEGER                       Apply color quantization. [default: -1]            │
│ --help                                                           Show this message and exit.                        │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
img2art path/to/image --scale 0.5 --with-color --threshold 127 --bg-color 255, 255, 255 --save-raw path/to/save.txt --alpha --quant 16

Reference

bobibo

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

img2art-0.4.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

img2art-0.4.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file img2art-0.4.0.tar.gz.

File metadata

  • Download URL: img2art-0.4.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.1

File hashes

Hashes for img2art-0.4.0.tar.gz
Algorithm Hash digest
SHA256 3c846cdb80537167912cba41566fafdfedf75213f9a00c6167a4be8b1473e85d
MD5 93007d30202b1d99da79d04116ec5100
BLAKE2b-256 a96500da25bf3ab05903c4a1f86f2170714a2bb464daeab301f105548e140dd9

See more details on using hashes here.

File details

Details for the file img2art-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: img2art-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.1

File hashes

Hashes for img2art-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9b6bef64df866fe872cc9503bebd9fc0ca6c6951ee472c94495e91502ce34aa1
MD5 90cdf65d3a3c3ee5e18a48defefdc64d
BLAKE2b-256 d0c156b02e27e6d140d6bfa27b2d92a21f48bd22ce3908331dcfadea3ab8f0a7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page