3 个不稳定版本
0.2.0 | 2023 年 1 月 23 日 |
---|---|
0.1.1 | 2022 年 6 月 25 日 |
0.1.0 | 2021 年 4 月 1 日 |
#99 in 可视化
65KB
1.5K SLoC
img2text
img2text
在终端上
img2text
Image-to-text converter
⠀⠀⠀⠀⠀⠀⠀⢠⣄⣠⣶⣤⣿⣤⣶⣄⣠⡄⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣄⣸⣿⣾⡿⠿⠛⢿⣀⡿⠛⠿⢿⣷⣿⣇⣠⠀⠀⠀⠀
⠀⠀⢠⣤⣿⣿⣛⣁⣀⣀⣀⣀⣉⣀⣀⣀⡀⠈⠛⢿⣿⣤⡄⠀⠀
⠀⠲⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡄⠈⣿⣿⣷⠖⠀
⠐⢾⣿⣤⠼⠇⢸⣿⣿⣿⣇⣀⣀⣀⣹⣿⣿⣿⠇⠸⢧⣤⣿⡷⠂
powered by: ⠰⢿⣿⡇⠀⠀⢸⣿⣿⣿⡿⠿⠿⢿⣿⣿⣿⣦⠀⠀⢀⣸⣿⡿⠆
⠐⠿⣿⣷⣤⣤⣼⣿⣿⣿⣧⣤⣄⠀⢻⣿⣿⣿⣦⣤⣾⣿⣿⠿⠂
⠀⠚⢿⣿⣿⡿⠿⠿⠿⠿⠿⠿⠿⠀⠈⠻⠿⠿⠿⢿⣿⣿⡿⠓⠀
⠀⠀⠘⠛⣿⣿⡟⢻⡆⠀⠀⠀⠀⠀⠀⠀⣸⠛⢳⣿⣿⠛⠃⠀⠀
⠀⠀⠀⠀⠉⢹⡿⢿⣿⣷⣶⣶⣶⣶⣶⣾⣿⡿⢿⡏⠉⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠈⠉⠘⠟⠙⠿⠋⠻⠃⠉⠁⠀⠀⠀⠀⠀⠀⠀
(The above image was generated by this program with an option `-s 25`.)
USAGE:
img2text [OPTIONS] <FILE>
ARGS:
<FILE>
The image to process
FLAGS:
-d, --dither
Apply dithering to preserve the gray shades. Incompatible with `-i
edge-canny`
-h, --help
Prints help information
-V, --version
Prints version information
OPTIONS:
-w <cell-width>
The width of output characters, only used when `-s` is given without
`!` [default: 0.45]
--dither-contrast <dither-contrast>
Choose the contrast enhancing technique to use for dithering
[default: median-quant] [possible values: none, median-quant,
equalize]
--canny-high-threshold <edge-canny-high-threshold>
A parameter for the Canny edge detector (`-i edge-canny`).
Edges with a strength higher than the high threshold will always
appear as edges in the output image. [default: 20]
--canny-low-threshold <edge-canny-low-threshold>
A parameter for the Canny edge detector (`-i edge-canny`).
Edges with a strength higher than the low threshold will appear in
the output image if there are strong edges nearby. [default: 10]
-i <input-ty>
Specifies how to interpret the input image [default: auto] [possible
values: auto, wob, bow, edge-canny]
-s <out-size>
The output size, measured in character cells or percents (e.g.,
`80`, `80x40`, `80x40!`, `-80x40`, `100%`). [default: downscale to
terminal size (if the output is a terminal) or 100% (otherwise)]
- 80: Fit within 80x80 character cells
- 80x40: Fit within 80x40 character cells, upscaling as necessary
- -80x40: Fit within 80x40 character cells, only downscaling
- 80x40!: Fit to 80x40 character cells, not maintaining the aspect
ratio
- 150%: Scale by 150%. The actual output size depends on the glyph
set being used; for example, `2x3` maps each 2x3 block to one
character.
-g <style>
The glyph set to use [default: braille] [possible values: slc,
ms2x3, 1x1, 1x2, 2x2, 2x3, braille]
安装
首先,请确保已安装 rustup 或 Rust 1.49.0 或更高版本。然后运行以下命令
cargo install img2text
这将编译并安装 img2text
命令行应用程序到 ~/.cargo/bin
或您系统中的其他位置。
推荐字体
Fairfax HD 可以显示此程序生成的所有字符(尤其是 Legacy Computing Symbols)。
img2text
在网页上
https://img2text.yvt.jp 是一个单页静态网站。
开发
先决条件
wasm-pack
cargo-license
extrude-licenses
- Binaryen
- rustup
- lessc
- FontTools
- ... 或者只需使用 Nix 并运行
nix develop
以安装所有这些 - (可选)
cargo-watch
cd web
make
python -m http.server
持续重建
cd web/static
python -m http.server &
cd ..
cargo watch -s make -i static
img2text
在您的应用程序中
将以下内容添加到您的应用程序的 Cargo.toml
文件中
[dependencies]
img2text = { version = "0.1.0", default-features = false }
依赖项
~0.1–17MB
~153K SLoC