项目作者: MikeRalphson

项目描述 :
Convert PNG/JPEG/GIFs to colourful terminal ANSI art. Based on
高级语言: JavaScript
项目地址: git://github.com/MikeRalphson/ansir-js.git
创建时间: 2018-11-04T02:34:57Z
项目社区:https://github.com/MikeRalphson/ansir-js

开源协议:Apache License 2.0

下载


ANSIR

Build Status

Generate UTF-8 Art from PNG using ANSI color codes.

Similar to oldschool ANSI art, we use UTF-8 block characters and standard terminal color escape sequences.

Supports both the basic and extended ANSI color escape sequences. Note: Full 24-bit RGB escape sequences currently not supported.

A utility conv.js can be used to convert JPEGs etc to PNG format.

Installation

  1. npm install -g ansir

Generate artwork

  1. ansir sample/in.png

Proportionally rescale the png file on the fly

  1. ansir --scale 0.1 sample/in.png > sample/out.ans

Sample

Input

input

Output (10% scale)

output

Renderers

Ansir supports 3 modes of rendering, shown in the following table:

Block Shaded Sub
block shaded sub

Usage

  1. Usage: ansir <png>
  2. Generate UTF-8 Art from PNG using ANSI color codes.
  3. Options:
  4. -h, --help output usage information
  5. -s, --scale <float> Proportionally rescale image
  6. -w, --width <integer> Target output width (in characters)
  7. -h, --height <integer> Target output height (in lines)
  8. --colors <basic|extended>
  9. The ANSI colorspace. Use "basic" for the most compatible 8-color
  10. palette. The default is "extended" for the 256-color palette supported by
  11. most major terminals that have any color at all.
  12. --background <light|dark>
  13. Applies only to "shaded" mode. Specifies whether the target terminal
  14. will have a light or dark background. This determines color matching for
  15. shaded UTF-8 block characters. Default is "dark", which means we interpret
  16. a shaded block character as darker than a solid one.
  17. --alpha-cutoff <float>
  18. The minimum alpha value of a pixel that should be converted to a ansi
  19. color utf-8 block character. Valid values are 0.0-1.0. Default is
  20. 0.95.
  21. --mode <block|shaded|sub>
  22. The rendering mode. Default is "block". The options are:
  23. "block" - Use the ANSI background escape sequence to create seamless blocks.
  24. "shaded" - Use the ANSI foreground escape sequence on unicode block character.
  25. LIGHT SHADE
  26. MEDIUM SHADE
  27. DARK SHADE
  28. FULL BLOCK
  29. "sub" - Use the ANSI foreground escape sequence on unicode quadrant block
  30. characters. NOTE: These characters can cause slowness when used
  31. with some common terminal fonts such as Consolas.
  32. QUADRANT UPPER LEFT
  33. QUADRANT UPPER RIGHT
  34. QUADRANT LOWER LEFT
  35. QUADRANT LOWER RIGHT
  36. QUADRANT UPPER LEFT AND LOWER RIGHT
  37. QUADRANT UPPER RIGHT AND LOWER LEFT
  38. FULL BLOCK

Resources

https://en.wikipedia.org/wiki/ANSI_art

http://ascii-table.com/ansi-escape-sequences.php