Skip to content

stong/img2txt

gh-pages
Switch branches/tags
Code
This branch is 9 commits ahead of hit9:gh-pages.
Contribute

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

img2txt

Image to Ascii Text, can output to html or ansi terminal.

See also gif2txt for animated version.

Supports "subpixel" rendering by choosing characters strategically. And that is even hardware-accelerated with CUDA if you want. LOL

Example

  1. img2txt.py jiaozhu.jpg > without-color.html : demo
  2. img2txt.py jiaozhu.jpg --dither > without-color-dither.html : demo
  3. img2txt.py jiaozhu.jpg --color > with-color.html: demo
  4. img2txt.py jiaozhu.jpg --dither --antialias --ansi --subpixel 32: demo

Installation

$ virtualenv venv
$ . venv/bin/activate
(venv)$ pip install img2txt.py

Usage

Usage:
  img2txt.py <imgfile> [--maxLen=<n>] [--fontSize=<n>] [--color] [--ansi] [--bgcolor=<#RRGGBB>] [--targetAspect=<n>] [--antialias] [--dither] [--subpixel=<n>] [--subpixel-font=<font.ttf>] [--gpu]
  img2txt.py (-h | --help)

Options:
  -h --help             show this screen.
  --ansi                output an ANSI rendering of the image
  --color               output a colored HTML rendering of the image.
  --antialias           causes any resizing of the image to use antialiasing
  --dither              dither the colors to web palette. Useful when converting
                        images to ANSI (which has a limited color palette)
  --fontSize=<n>        sets font size (in pixels) when outputting HTML,
                        default: 7
  --maxLen=<n>          resize image so that larger of width or height matches
                        maxLen, default: 100px
  --bgcolor=<#RRGGBB>   if specified, is blended with transparent pixels to
                        produce the output. In ansi case, if no bgcolor set, a
                        fully transparent pixel is not drawn at all, partially
                        transparent pixels drawn as if opaque
  --targetAspect=<n>    resize image to this ratio of width to height. Default is
                        1.0 (no resize). For a typical terminal where height of a
                        character is 2x its width, you might want to try 0.5 here
  --subpixel=<n>        perform subpixel rendering, with scale factor n
  --subpixel-font=<f>   font to assume for subpixel rendering. must be TTF format
  --gpu                 perform subpixel rendering with CUDA on GPU.

Authors

  • @EdRowe (#4, #7)
  • @shakib609 (#10)
  • @mattaudesse (#11)
  • @hit9
  • @stong

License

BSD.

About

GPU-accelerated ascii art generator with subpixel rendering

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 90.4%
  • Python 9.6%