はじめに
chafa
というソフトを見つけたので使ってみる。
https://packages.ubuntu.com/noble/graphics/chafa
- hpjansson / chafa
https://github.com/hpjansson/chafa
環境
Windows 11 Professional
WSL2 Ubuntu 24.04 LTS
chafaのインストール
sudo apt-get install chafa
ログ
sudo apt-get install chafa
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libgl1-amber-dri libllvm19 libxcb-damage0 mesa-utils-bin xbitmaps
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libavif16 libchafa0t64 libgav1-1 libyuv0
The following NEW packages will be installed:
chafa libavif16 libchafa0t64 libgav1-1 libyuv0
0 upgraded, 5 newly installed, 0 to remove and 20 not upgraded.
Need to get 817 kB of archives.
After this operation, 2431 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu noble/universe amd64 libchafa0t64 amd64 1.14.0-1.1build1 [117 kB]
Get:2 http://archive.ubuntu.com/ubuntu noble/universe amd64 libgav1-1 amd64 0.18.0-1build3 [357 kB]
Get:3 http://archive.ubuntu.com/ubuntu noble/universe amd64 libyuv0 amd64 0.0~git202401110.af6ac82-1 [178 kB]
Get:4 http://archive.ubuntu.com/ubuntu noble/universe amd64 libavif16 amd64 1.0.4-1ubuntu3 [91.2 kB]
Get:5 http://archive.ubuntu.com/ubuntu noble/universe amd64 chafa amd64 1.14.0-1.1build1 [73.1 kB]
Fetched 817 kB in 2s (435 kB/s)
Selecting previously unselected package libchafa0t64:amd64.
(Reading database ... 89538 files and directories currently installed.)
Preparing to unpack .../libchafa0t64_1.14.0-1.1build1_amd64.deb ...
Unpacking libchafa0t64:amd64 (1.14.0-1.1build1) ...
Selecting previously unselected package libgav1-1:amd64.
Preparing to unpack .../libgav1-1_0.18.0-1build3_amd64.deb ...
Unpacking libgav1-1:amd64 (0.18.0-1build3) ...
Selecting previously unselected package libyuv0:amd64.
Preparing to unpack .../libyuv0_0.0~git202401110.af6ac82-1_amd64.deb ...
Unpacking libyuv0:amd64 (0.0~git202401110.af6ac82-1) ...
Selecting previously unselected package libavif16:amd64.
Preparing to unpack .../libavif16_1.0.4-1ubuntu3_amd64.deb ...
Unpacking libavif16:amd64 (1.0.4-1ubuntu3) ...
Selecting previously unselected package chafa.
Preparing to unpack .../chafa_1.14.0-1.1build1_amd64.deb ...
Unpacking chafa (1.14.0-1.1build1) ...
Setting up libchafa0t64:amd64 (1.14.0-1.1build1) ...
Setting up libgav1-1:amd64 (0.18.0-1build3) ...
Setting up libyuv0:amd64 (0.0~git202401110.af6ac82-1) ...
Setting up libavif16:amd64 (1.0.4-1ubuntu3) ...
Setting up chafa (1.14.0-1.1build1) ...
Processing triggers for man-db (2.12.0-4build2) ...
Processing triggers for libc-bin (2.39-0ubuntu8.4) ...
インストール確認
chafa --version
Chafa version 1.14.0
Loaders: AVIF GIF JPEG PNG QOI SVG TIFF WebP XWD
Features: mmx sse4.1 popcnt avx2
Applying: mmx sse4.1 popcnt avx2
Copyright (C) 2018-2023 Hans Petter Jansson et al.
Incl. libnsgif copyright (C) 2004 Richard Wilson, copyright (C) 2008 Sean Fox
Incl. LodePNG copyright (C) 2005-2018 Lode Vandevenne
Incl. QOI decoder copyright (C) 2021 Dominic Szablewski
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
chafaを使う
ヘルプを確認する
chafa --help
Usage:
chafa [OPTION...] [FILE...]
Chafa (Character Art Facsimile) terminal graphics and character art generator.
General options:
-h, --help Show help.
--version Show version.
-v, --verbose Be verbose.
Output encoding:
-f, --format=FORMAT Set output format; one of [iterm, kitty, sixels,
symbols]. Iterm, kitty and sixels yield much higher
quality but enjoy limited support. Symbols mode yields
beautiful character art.
-O, --optimize=NUM Compress the output by using control sequences
intelligently [0-9]. 0 disables, 9 enables every
available optimization. Defaults to 5, except for when
used with "-c none", where it defaults to 0.
--relative=BOOL Use relative cursor positioning [on, off]. When on,
control sequences will be used to position images relative
to the cursor. When off, newlines will be used to separate
rows instead for e.g. 'less -R' interop. Defaults to off.
--passthrough=MODE Graphics protocol passthrough [auto, none, screen,
tmux]. Used to show pixel graphics through multiplexers.
--polite=BOOL Polite mode [on, off]. Inhibits escape sequences that may
confuse other programs. Defaults to off.
Size and layout:
--align=ALIGN Horizontal and vertical alignment (e.g. "top,left").
--clear Clear screen before processing each file.
--exact-size=MODE Try to match the input's size exactly [auto, on, off].
--fit-width Fit images to view's width, possibly exceeding its height.
--font-ratio=W/H Target font's width/height ratio. Can be specified as
a real number or a fraction. Defaults to 1/2.
--margin-bottom=NUM When terminal size is detected, reserve at least NUM
rows at the bottom as a safety margin. Can be used to
prevent images from scrolling out. Defaults to 1.
--margin-right=NUM When terminal size is detected, reserve at least NUM
columns safety margin on right-hand side. Defaults to 0.
--scale=NUM Scale image, respecting view's dimensions. 1.0 approximates
image's pixel dimensions. Specify "max" to fit view.
Defaults to 1.0 for pixel graphics and 4.0 for symbols.
-s, --size=WxH Set maximum image dimensions in columns and rows. By
default this will be equal to the view size.
--stretch Stretch image to fit output dimensions; ignore aspect.
Implies --scale max.
--view-size=WxH Set the view size in columns and rows. By default this
will be the size of your terminal, or 80x25 if size
detection fails. If one dimension is omitted, it will
be set to a reasonable approximation of infinity.
Animation and timing:
--animate=BOOL Whether to allow animation [on, off]. Defaults to on.
When off, will show a still frame from each animation.
-d, --duration=SECONDS How long to show each file. If showing a single file,
defaults to zero for a still image and infinite for an
animation. For multiple files, defaults to zero. Animations
will always be played through at least once.
--speed=SPEED Animation speed. Either a unitless multiplier, or a real
number followed by "fps" to apply a specific framerate.
--watch Watch a single input file, redisplaying it whenever its
contents change. Will run until manually interrupted
or, if --duration is set, until it expires.
Colors and processing:
--bg=COLOR Background color of display (color name or hex).
-c, --colors=MODE Set output color mode; one of [none, 2, 8, 16/8, 16, 240,
256, full]. Defaults to best guess.
--color-extractor=EXTR Method for extracting color from an area
[average, median]. Average is the default.
--color-space=CS Color space used for quantization; one of [rgb, din99d].
Defaults to rgb, which is faster but less accurate.
--dither=DITHER Set output dither mode; one of [none, ordered,
diffusion]. No effect with 24-bit color. Defaults to none.
--dither-grain=WxH Set dimensions of dither grains in 1/8ths of a
character cell [1, 2, 4, 8]. Defaults to 4x4.
--dither-intensity=NUM Multiplier for dither intensity [0.0 - inf].
Defaults to 1.0.
--fg=COLOR Foreground color of display (color name or hex).
--invert Swaps --fg and --bg. Useful with light terminal background.
-p, --preprocess=BOOL Image preprocessing [on, off]. Defaults to on with 16
colors or lower, off otherwise.
-t, --threshold=NUM Lower threshold for full transparency [0.0 - 1.0].
Resource allocation:
--threads=NUM Maximum number of CPU threads to use. If left unspecified
or negative, this will equal available CPU cores.
-w, --work=NUM How hard to work in terms of CPU and memory [1-9]. 1 is the
cheapest, 9 is the most accurate. Defaults to 5.
Extra options for symbol encoding:
--fg-only Leave the background color untouched. This produces
character-cell output using foreground colors only.
--fill=SYMS Specify character symbols to use for fill/gradients.
Defaults to none. See below for full usage.
--glyph-file=FILE Load glyph information from FILE, which can be any
font file supported by FreeType (TTF, PCF, etc).
--symbols=SYMS Specify character symbols to employ in final output.
See below for full usage and a list of symbol classes.
Accepted classes for --symbols and --fill:
all ascii braille extra imported narrow solid ugly
alnum bad diagonal geometric inverted none space vhalf
alpha block digit half latin quad stipple wedge
ambiguous border dot hhalf legacy sextant technical wide
These can be combined with + and -, e.g. block+border-diagonal or all-wide.
Examples:
$ chafa --scale max in.jpg # As big as will fit
$ chafa --clear --align mid,mid -d 5 *.gif # A well-paced slideshow
$ chafa -f symbols --symbols ascii -c none in.png # Old-school ASCII art
If your OS comes with manual pages, you can type 'man chafa' for more.
使ってみる
オリジナル画像

chafa [画像ファイル名]
結果

参考
パッケージ: chafa (1.14.0-1.1build1) [universe] | ubuntu packages
https://packages.ubuntu.com/noble/graphics/chafahpjansson / chafa
https://github.com/hpjansson/chafa
おわりに
chafa
というパッケージを使ってみた。
画像をターミナルで表示できる系(というより文字に変換して表示している系)ですね。