GithubHelp home page GithubHelp logo

stefanhaustein / terminalimageviewer Goto Github PK

View Code? Open in Web Editor NEW
1.5K 35.0 111.0 2.51 MB

Small C++ program to display images in a (modern) terminal using RGB ANSI codes and unicode block graphics characters

License: Other

Java 0.53% C++ 99.42% Makefile 0.02% Ruby 0.03%
terminal-graphics ansi-colors cpp ascii-graphics

terminalimageviewer's Introduction

Terminal Image Viewer (tiv)

Small C++ program to display images in a (modern) terminal using RGB ANSI codes and unicode block graphic characters.

There are various similar tools (such as timg) that use the unicode half block character to display two 24bit pixels per character cell. This program enhances the resolution by mapping 4x8 pixel cells to different unicode characters, using the following algorithm for each 4x8 pixel cell of the (potentially downscaled) image:

  1. Find the color channel (R, G or B) that has the biggest range of values for the current cell
  2. Split this range in the middle and create a corresponding bitmap for the cell
  3. Compare the bitmap to the assumed bitmaps for various unicode block graphics characters
  4. Re-calculate the foreground and background colors for the chosen character.

See the difference by disabling this optimization using the -0 option. Or just take a look at the comparison image at the end of this text.

Usage

tiv [options] <filename> [<filename>...]

The shell will expand wildcards. By default, thumbnails and file names will be displayed if more than one image is provided. For a list of options, run the command without any parameters or with --help.

News

  • 2024-03-20: Added a section on how to use the API.
  • 2024-02-01: We are currently working on splitting the source code into dependency-free library files and a client that uses CImg.
  • 2023-09-29: Today marks the 40th anniversary of the GNU project. If you haven't learned the news concerning it and Stallman, please do. Support for MSVC has been added and the repository is now under an Apache 2.0 or GPL3 dual license. CI building for each release will hopefully be setup soon. The main program has also adopted a mostly Google code-style because I (aaron) think it simply makes sense. SPDX-License-Identifier: Apache-2.0 OR GPL-3.0-or-later
  • 2021-05-22: We now support Apple Clang, thanks to the C++ filesystem library being no longer experimental. Issue forms have also been added to the GitHub repository.
  • 2020-10-22: The Java version is now deprecated. Development has long shifted to the C++ version since that was created, and the last meaningful update to it was in 2016.

Installation

Important

All installation methods require installing ImageMagick, a required dependency. Most package managers should install it automatically.

All platforms: Build from source

Our makefile currently only supports g++. It should be possible to compile tiv manually using any of your favorite compilers that support C++17 and Unix headers (ioctl.h and sysexits.h, specifically) or windows.h. PRs are welcome.

git clone https://github.com/stefanhaustein/TerminalImageViewer.git
cd TerminalImageViewer/src
make

# To move the tiv binary into your PATH (hopefully), also do
sudo make install

Please don't forget to install ImageMagick... On Debian based Linux via sudo apt install imagemagick and on MacOS via brew install imagemagick.

Mac: Homebrew

brew install tiv

As the original Apple Shell only supports 256 color mode (-256) and there seems to be some extra line spacing, distorting the image, we also recommend installing iTerm2:

brew install --cask iterm2

Third-Party Packages

Common problems / Troubleshooting

  • Errors such as "unrecognized file format"? Make sure ImageMagic is installed.
  • On some linux platforms, an extra flag seems to be required: make LDLIBS=-lstdc++fs (but it also breaks MacOs), see #103
  • If you see strange horizontal lines, the characters don't fully fill the character cell. Remove additional line spacing in your terminal app
  • Wrong colors? Try -256 to use a 256 color palette instead of 24 bit colors
  • Strange characters? Try -0 or install an use full unicode font (e.g. inconsolata or firacode)

Using the TIV API

Tiv can be used as an API. So if you always wanted to run your favorite FPS in a shell, this is the opportunity.

All the code useful as a library is isolated in tiv_lib.h and tiv_lib.cc.

The main entry point is

CharData findCharData(GetPixelFunction get_pixel, int x0, int y0, const int &flags)

The call takes a std::Function that allows the TIV code to request pixels from your framebuffer.

From this framebuffer, the call will query pixels for a 4x8 pixel rectangle, where x0 and y0 define the top left corner. The call searches the best unicode graphics character and colors to approximate this cell of the image, and returns these in a CharData struct.

Contributions

  • 2019-03-26: Exciting week: @cabelo has fixed output redirection, @boretom has added cross-compilation support to the build file and @AlanDeSmet has fixed tall thumbnails and greyscale images.
  • 2020-07-05: @cxwx has fixed homebrew support.

I am happy to accept useful contributions under the Apache 2.0 license, but...

  • Before investing in larger contributions, please use an issue to discuss this
  • Pull requests should be as "atomic" as possible. I won't accept any pull request doing multiple things at once.
  • This program currently only depends on CImg and ImageMagick as image processing libraries and I'd prefer to keep it that way.
  • Support for additional platforms, CPUs or similar will require somebody who is happy to help with maintenance, in particular if I don't have access to it.

Examples

Most examples were shot with the Java version of this program, which should have equivalent output but slower by millenia in CPU years.

Examples

If multiple images match the filename spec, thumbnails are shown.

Thumbnails

For the example below, the top image was generated with the character optimization disabled via the -0 option.

Comparison

Licensing

You are free to use this code under either the GPL (3 or later) or version 2.0 of the Apache license. We include the CImg library, which is licensed under either CeCILL 2.0 (close to GPL and compatible with it) or [CeCILL-C] (https://spdx.org/licenses/CECILL-C) (close to LGPL and compatible with Apache).

terminalimageviewer's People

Contributors

aaronliu0130 avatar actions-user avatar admirabilis avatar alandesmet avatar boretom avatar bperel avatar cabelo avatar chen3feng avatar crouvpony47 avatar cszach avatar dmole avatar dtschump avatar hadisfr avatar hialmar avatar huell-howitzer avatar jwilk avatar nik123 avatar penguin359 avatar pepa65 avatar profelis avatar qsantos avatar rindeal avatar shabbyrobe avatar stefanhaustein avatar timoteostewart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terminalimageviewer's Issues

Which terminals does this work well with?

I stumbled across this page and thought it was a really cool idea, so I tried something similar in a project I'm working on. (Not being Java-based, I can't directly use your code, but my re-implementation was certainly inspired by your ideas.)

But one thing I noticed right away is that on my Mac (where I'm using iTerm2), the rendering of the unicode block characters doesn't quite fill the character cell. So, for example, if it wants the top half to be "foreground" color and the bottom half to be the background color, you'll still see a bit of the background at the top of the cell, if you understand what I'm getting at. This really screws up the appearance versus the neat images you show on the project page.

So I'm wondering what advice you might have -- which terminal emulation programs, which platforms, which fonts are known to work or not work? And do you have any thoughts about "auto-detection" about whether the unicode characters are supported, and/or if the 24-bit color ANSI codes are supported? Must a user know that in advance and only use a display scheme like this if they somehow know, or is there a way for a program to figure out whether it's likely that the terminal being used at the moment supports it?

Transparency support for PNG

there seems to be no support for alpha channel on PNG's / Gifs, is that a possibility? atleast on fully transparent rgba(0,0,0,0) pixels.

Feature request: support upscaling

I'd like to use tiv to replace some uses that I already use timg for, since it generally produces better results; however, they require it to be able to emit images exactly scaled to fit the tty height. tiv's -w and -h settings only set upper bounds on the image size, though; it won't upscale.

sh: 1: convert: not found

# ./tiv e.jpg 
sh: 1: convert: not found
sh: 1: gm: not found
sh: 1: convert: not found
sh: 1: gm: not found
sh: 1: convert: not found
sh: 1: gm: not found

[CImg] *** CImgIOException *** [instance(0,0,0,0,(nil),non-shared)] CImg<unsigned char>::load(): Failed to recognize format of file 'e.jpg'.
File format not recogmized for 'e.jpg'

# file tiv
tiv: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=7d7a066788b8a442acee9a988c25e0f67833ff95, stripped

# grep convert tiv.cpp

# uname -r
4.9.41-00428-g6553404

ranger support

This is absolutely stunning work. Thanks

How can I use this in ranger as the default image previewer?

homebrew file need update,

mac homebrew mv gcc to /usr/local/opt/gcc
not in /usr/local

new libstdc++fs at /usr/local/opt/gcc/lib

ld: library not found for -lstdc++fs
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Noisy color output with indexed-color, few-color source images.

LOVE it! However I can't get indexed-color images to come out with a clean mapping of colors.

The best I could do with the Google logo was this: http://imgur.com/8yZJpgOl.png

I would love it if the program could limit output colors to the colors used in an indexed-color image, or if you could limit it to the 16 colors used in IRC. https://en.wikichip.org/wiki/irc/colors
Also awesome would be if it could output IRC colors directly (control code 0x03+FG_COLOR,BG_COLOR) before each color change, but I can do that with a script.

I'd gladly donate to help. Can't program well enough to do it myself :( CHEERS

images smaller than terminal

in 120+ terminal, the image is just 86 wide

option -w 120, changes nothing
option -w 200, changes nothing

option -W 200 makes the image very small!

Possible typo with "light down"

Just noticed something odd in the code; it seems that even though the comment says "light down", it is using the codepoint for "light up":

0x44440000, 0x2575, // light up

  0x44440000, 0x2575,  // light up
  0x22220000, 0x2575,  // light up
  0x00030000, 0x2576,  // light right
  0x00003000, 0x2576,  // light right
  0x00004444, 0x2575,  // light down
  0x00002222, 0x2575,  // light down

If "light down" is actually what is wanted, the codepoint is 0x2577.

A way to install the app

Right now the javac create bunch of class files from source file, and you need to call it from the directory where you compile it. There should be a way to install the app, for instance create jar file and bash script that will call the java with the jar file.

Core dump when providing directory as argument

$ tiv ~/Downloads/
terminate called after throwing an instance of 'cimg_library::CImgArgumentException'
  what():  [instance(0,0,0,0,(nil),non-shared)] CImg<char>::load_raw(): Specified filename '/home/omar/Downloads/' is a directory.
Aborted (core dumped)

Can tiv just recurse through the directory and show all files within it rather than blow up?

File format is not rcognized

Using kali linux environment inside windows 10, cant get your tool to open any image files, constantly get this error;

$ tiv "banana split.png" -0

[CImg] *** CImgIOException *** [instance(0,0,0,0,(nil),non-shared)] CImg::load(): Failed to recognize format of file 'banana split.png'.
File format is not recognized for 'banana split.png'

User customizable BITMAPS

Users may have a variety of reasons for wanting a different set of BITMAPS:

  • User wants to use new characters not yet known to TIV. (I'm really looking forward to the Teletext block mosaic and smooth mosaic terminal graphics characters)
  • User is using a font that doesn't yet support some of the characters TIV uses.
  • User is using a font with some unusually shaped characters, such that different bit patterns work better.

My broad proposal is to allow the user to create a configuration file with an alternative set of characters and bit maps. Probably available at a well known location ($XDG_DATA_HOME/tivrc falling back to $HOME/.tivrc?), perhaps overridable via environment variable or command line?

For simplicity, I don't propose doing anything clever like trying to merge user configuration with the built-in configuration; it's all or nothing.

A command line option to create a default configuration file from the built-in configuration is probably necessary in practice.

In the longer term, tools to help create the file would be useful, but are probably best left to a later. Possibilities I see:

  • Automatically probing which characters exist for a given font. Tools like fc-list 'FONTNAME:style=Regular' charset, fc-list -v 'FONTNAME:style=Regular', or hb-shape PATH/TO/FONT '┣'
  • Given enough information about a terminal (at the very least, how to find the character at 0,0), an automatic set of bit patterns could be generated.

Specify the number of pictures to print in dir mode

Hello ! Here is what I noticed.
When printing a directory with -h there is no need to go through all pictures but only a few subset of the the firsts because only thoses ones need to be displayed. It willl be faster

support jpg images

103 ~ xpix Downloads/gd.jpg
Exception in thread "main" javax.imageio.IIOException: Can't read input file!
at javax.imageio.ImageIO.read(ImageIO.java:1301)
at TerminalImageViewer.loadImage(TerminalImageViewer.java:139)
at TerminalImageViewer.convert(TerminalImageViewer.java:116)
at TerminalImageViewer.main(TerminalImageViewer.java:73)

Ran into issue compiling with openjdk

Would say 100 times TerminalImageViewer.java:305: error: unmappable character for encoding ASCII
0x06600660, '\u254f', //??Heavy double dash vertical

Found adding " -encoding ISO-8859-1" to javac fixed it.

Snap package: support for file systems mounted under the "/mnt" and "/media"

I have installed tiv via snap on Ubuntu 18.04. Unfortunately I am unable to browse images in file systems mounted on "/mnt". Every time I try to open image inside "/mnt" I get error message:

[CImg] *** CImgIOException *** [instance(0,0,0,0,(nil),non-shared)] CImg<unsigned char>::load(): Failed to open file '0_webcam_1.jpg'.
File format is not recognized for '0_webcam_1.jpg'

According to the documentation the removable-media interface should be enabled.

A heap-buffer-overflow occurred when running ./tiv

A heap-buffer-overflow occurred when running ./tiv

=================================================================
==11827==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f198849ca48 at pc 0x0000004701ba bp 0x7fffb2b08940 sp 0x7fffb2b08930
READ of size 1 at 0x7f198849ca48 thread T0
    #0 0x4701b9  (/home/sandy/swt_fuzz/TerminalImageViewer/src/main/cpp/tiv+0x4701b9)
    #1 0x45e988  (/home/sandy/swt_fuzz/TerminalImageViewer/src/main/cpp/tiv+0x45e988)
    #2 0x44e45c  (/home/sandy/swt_fuzz/TerminalImageViewer/src/main/cpp/tiv+0x44e45c)
    #3 0x4299be  (/home/sandy/swt_fuzz/TerminalImageViewer/src/main/cpp/tiv+0x4299be)
    #4 0x421801  (/home/sandy/swt_fuzz/TerminalImageViewer/src/main/cpp/tiv+0x421801)
    #5 0x406fd0  (/home/sandy/swt_fuzz/TerminalImageViewer/src/main/cpp/tiv+0x406fd0)
    #6 0x7f19864fe82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #7 0x403338  (/home/sandy/swt_fuzz/TerminalImageViewer/src/main/cpp/tiv+0x403338)

0x7f198849ca48 is located 0 bytes to the right of 148040-byte region [0x7f1988478800,0x7f198849ca48)
allocated by thread T0 here:
    #0 0x7f19873ff6b2 in operator new[](unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x996b2)
    #1 0x44f3cb  (/home/sandy/swt_fuzz/TerminalImageViewer/src/main/cpp/tiv+0x44f3cb)
    #2 0x42a2bb  (/home/sandy/swt_fuzz/TerminalImageViewer/src/main/cpp/tiv+0x42a2bb)
    #3 0x46e35a  (/home/sandy/swt_fuzz/TerminalImageViewer/src/main/cpp/tiv+0x46e35a)
    #4 0x45e988  (/home/sandy/swt_fuzz/TerminalImageViewer/src/main/cpp/tiv+0x45e988)
    #5 0x44e45c  (/home/sandy/swt_fuzz/TerminalImageViewer/src/main/cpp/tiv+0x44e45c)
    #6 0x4299be  (/home/sandy/swt_fuzz/TerminalImageViewer/src/main/cpp/tiv+0x4299be)
    #7 0x421801  (/home/sandy/swt_fuzz/TerminalImageViewer/src/main/cpp/tiv+0x421801)
    #8 0x406fd0  (/home/sandy/swt_fuzz/TerminalImageViewer/src/main/cpp/tiv+0x406fd0)
    #9 0x7f19864fe82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

SUMMARY: AddressSanitizer: heap-buffer-overflow ??:0 ??
Shadow bytes around the buggy address:
  0x0fe3b108b8f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fe3b108b900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fe3b108b910: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fe3b108b920: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fe3b108b930: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0fe3b108b940: 00 00 00 00 00 00 00 00 00[fa]fa fa fa fa fa fa
  0x0fe3b108b950: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe3b108b960: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe3b108b970: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe3b108b980: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe3b108b990: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
==11827==ABORTING

And the input file has been put at:
https://github.com/fCorleone/fuzz_programs/blob/master/TerminalImageViewer/test1

Compiling issues on MacOS 10.14.1

I'm unable to compile tiv on macos 10.14.1 where it used to work in the not too distant past.

when I try to compile latest source from github on macos, I get:

ross@Rosss-MacBook-Air:~/project/TerminalImageViewer/src/main/cpp$ make
g++ -std=c++17 -Wall -fpermissive -fexceptions -O2 -c tiv.cpp -o tiv.o
tiv.cpp:8:10: fatal error: 'experimental/filesystem' file not found
#include <experimental/filesystem>
^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [tiv.o] Error 1

Failed to recognize format

I build the c++ version on raspbian and ubuntu 18, both give me such error

[CImg] *** CImgIOException *** [instance(0,0,0,0,(nil),non-shared)] CImg<unsigned char>::load(): Failed to recognize format of file 'image.jpg'. File format is not recognized for 'image.jpg'.

Also tried the png file but still not work. Any clue?

Redirecting tiv output

Am I the only user who gets files of size 0 when i try to redirect tiv output?

Doesn't std::cout allow redirection?

The last lines of pixels are missing

If I view the minetest mese texture upscaled by a factor of 8, the lowest pixels are missing:

mese (8x):
default_mese

what tiv shows (and newlines put around it):
mese_tiv

Don't work on Ubuntu in xfce4-terminal

I've isntalled open jdk using:

sudo apt-get install default-jdk

which installed open-jdk-8 and when I've compiled java file and run the app I've got this in response:

terminal

How to speed it up

Thanks for this great app. The images look really awesome. I use Ubuntu 16.04, and a gnome-terminal.

A problem that I noticed is that the program is slow. It takes over a second to render a simple image.
As you can see below, I also try to render it to a file (over a second), and then just plot it using cat log. And just catting the file is immediate. So it's not he terminal slowing things down, it's the Java program.

Do you know what the bottleneck is and if there is a way to speed it up?

P.S. When you copy and paste from the terminal, you lose the color, so it's hard to see, but you can see the timings at least.

$ time java TerminalImageViewer -h 100 a.jpg 
⎼▁▇ ▝ ▎▅▇▇▇▆▅━▃▁ ▊╴▇▗┛ ▒▁▂▄▆ ▇━▝▗╴    ▗ ▄╴ ⎽▁▃▒▖╵▊ ▇  ▁▊▘▘▘▎ ╸▁▁─    ▝ ╹▃▒▅▁▃▄▆▄
▘▆▄▎▝▌┗┃ ⎽▅ ╶  ▅─▒▆▆▅ ▅▅▅▅▒▝▃╶▅ ▇▇⎼▁ ⎻╵  ⎻▚▂▂▃▂▃▘ ▎▗⎻▅▎▂▂▄▘╺ ⎼▒━▅    ▝▗━▃▆▗▖ ▝╹╴
 ▃▁ ▊ ╵▆  ▃▅▂┗▒▖ ▆▇▅▌▁ ▃▄▂▃▅  ╴▄▄▘  ▊━▊ ┛┛┛▎⎻⎺╵▒⎺╶╴┓▅▅▆▄━▅ ╺▄▃╵╵ ┓   ▌▅▁▌ ▁╵▎▁▁⎽
┛▗▅ ▊▘╹╺ ╴┛╶   ▁▚▎▇▁▂▆▝ ▄▄▃ ▂▁▄▅▃ ⎽⎼⎼▃▖ ▁▒▇  ▇┗▗╴╴▒─▅▃▒▆▖╵▒╵▒▃▒┗┓▗ ▊▘ ▆ ┻━▆▅▒▁▆▘
⎼▇▒▎▎  ▁▊ ▃ ╵▆⎻▝▌▅▊▂▌┗▄▄▂▂▅▇▂▚╴▊⎽╺ ╴ ▝⎻▄━▆▅▒▁━▂▅╵▂▂⎽▂▝▌▒▒   ▃▒╵▆╴▌▁▘╴╴  ┃▗▖  ▇─╴
 ╵⎼ ▁ ▎╵ ▁    ╵▊▚━▊▗▘━─▄ ▊▘⎺▂▁ ▊⎽│▂⎼⎼▌▖▗▄▒▂╹▃▊▅▆ ▎▇▅╏    ▒ ▎▘▄▄⎺▆▂╴╺╵▂▒╶╴▆ ⎺╶▁⎽╺
╹ ▇▘  ▒┓╶╴  ┏▃▆ ▒ ╺▅▒▅╶▁╹─╴▄    ▃▅▇⎼⎼│ ▝─━╴▝┗▆┗⎻ ━╴▊▒▇╸ ▁▃  ▁╵▘▊▁▊╴▗▂▃▖⎼▊▆⎼▃▂▂  
╴▁▄▘⎻▇▂▚▃ ▆│ ▃━▎ ╵▆▅▆  ╺│ ▒ ╴╴ ╺   ▗ ╵▘▝▁▒▅▖▁╋   ▄▝⎼▁ ╴     ▆▆▅▆▒▁▊▄▅▘ ⎺⎺╺▅▁▇▄▄▄
▒ ▃▝ ▝▇▊╸  ╵  ╴▘▅  ─▝  ▁▊⎼    ▎╸▘╺▁▝ ▝▌▝▂▒▁▚╸▃▘▝▊▘▄░▖╸▆╺    ╺⎽╏▂╵▝ ╺ ▃ ▁⎽  ▆▖▌ ▗
▝▅▃┛▃╺⎻▊▎─▄┗   ▌▁▂ ▁ ▁▇▇▝⎻ ▆ ▊━╴  ╴▆▅▃▊▂▃▚▘▇⎽▊┛▘ ╏▒▂▁⎼ ▂   ╴╴▆╴ ▆ ▅▅╸▇ ▂▃▘▁▄┻▄▂▆
╴▖╴▃ ▊ ┃▘▘ ┃▂ │  ▁▅▌⎺ ▊╸▊  ▇ ╸╵  ▆⎻⎺▒╴ ┗ ▒⎻▄▅ ▒▎  ▒  ▄⎻─▘⎺▆╵╶ ⎽ ⎽ ▄▆▁▃▄▆▇┗▘▗▃▌╴▁
┗  ▄ ▒╵▒▌│▇│━  ▅┗▘▆ ▆▅▆▝▖    ╴▊ ░▁▂▘▂▒━ ▒▝ ▌▅▅▎  ▎▂▒╴╶⎼╵▎ ╴ ─ ▘ ╹  ╸▅▃⎼▃▄▄▗▚  ▅▝
╵▄ ╺  ╸╴▊    ╏ ││▌▖▖ ─▁    ▁▃⎼╺▒─▅▄▆▊│ ╸▃╴╺ ▃▒ ▂╴▅⎺▚╴ ━⎻  ▂╵╴ ╵ ━▎  ╺╴▆▅▄▘┃▅   ╺
╸╴─  ─▒┏▒┛ ▌▖▂ ▘▌▃▂▁▁▗▅▗╴╸╸ ╺▁│ ▄ ▎▝▇▒⎻▄▚▒ ▁╶┓▗ ▗▂╵    ▗ ▗─⎼ ▆╴─▒▗▖ ▁▁▆▇ ▗ ┫▒━╹⎽
┫▒▎▁  ╴▘▖┃╵▃▇▘▝▆ ▄▎▄▝▆▎▆┃▎╏ ▁▁│╵ ▃▖─▎╵ ▒━⎽▂▁ ⎺▌╵─▇▚╵╴╵ ╸╵  ╺ ─⎺▇▒ ╵ ▇┏▅⎻━▂▆┓ ▂━━
▇ ╏╺ ▆⎽▊▇╺▄ ▅ ▗▂▊  ▅▄▊▌▅▁▖▊▃━▄┗│▁  ▚⎺▎╴▒    ╴╴╺▒▒ ▊▁━│▒▎ ╵╴  ╵▁╴    ⎺⎼   ▆▃━ ▝▊ 
  ▅┏ ▊  ▒▘▗▆▝▝▆▖▖ ▊▄▂▌  ▝▄▊▂━─▎ ╶╹╶▄╏┗▆ ▇▅⎽▇⎻━━─╺▒▊▊▅▎  ▊▒▁ ╴ ╴⎺ ▄ ▒▇▁▁▂┗⎽▘ ▌┏─▒
▌╸▇▆ ▊━   ▘▗╸▝▌▗▃▘ ▗▅   ▅▁▖▌ ▁▌ ╏▎╹  ▂▖━▝▖╴╴▝│ ▒┗▚┏▌⎼▅▁▊▒▒╏▒⎺╵   ▂▊▅▆▇ ▂ ▎━ ▂▃╴⎼
▎▁┏━  ▚┣▊┛▃┓▌▅▄▌▆ ▅ ▅▃▃▄▗▖  ▆▅▖ ▊│▘   ▝▂ ▊    ▆ ▌▌│▎▖▗▇╵▆┃▊▊  ╶▃ ⎽    ▇▒⎻╵╹ ▘│▌ 
⎽▄▅▖  ╏▌   ▊╺▃ ▘▃▊ ▝ ▄╶ ▖ ▚ ▊▆▆ ▘ ▇▗  ▊▆▝▒▃⎼╴▆▗ ▒ │▎▂▗┏▎╴▒░╸ ─ ╵ ▚╴▁  ⎽▌▎⎻ ▁▖▅▎▇
╺▒▒┃╸╵▃▂▂▎┏▘▁▂ ▖▁ ▝▃▁▗▖▅ ▂ ┓ ▄▆ ▘▃ ▗▅▎▊⎺╹▂ ▘ ▌▖▁╏▘─▒│▗▁╴  ▝▄▊▌▎ ━ ▗▂⎺╴▁▅─▗▗▆─   
▁▘▂▊▎ ▎▊▇▎▂▖▝▆ ▎ ▂⎼▆▎▊▌━ ▄┗▊▚▖▖▗▗▂│▊╸▎▊▇▅┗▃▁▗▄▎▌│╺┃━▘┏▇─⎺▆▁▗▊┃▎ ▊ ▅▖▎▅╹▒▃ ┗  ▊╸ 
╴▝▆▊▎ ▎▆ ▄▅ ▇▆ ▌▇▌ ▁▊ ▊▆▌▝─ ▚ ▌ ▎┃│▊▂ ▊  ▎▄▌▎▄▎ ╸▝▃▘▒▎ ▖▒╴▝▘▊▆▎▒▒▂▖▎▁▒▄▄▒▖╶▊ ▄ ▂
  ▊   ▎╺▎┗▎╵▃▂   ▁▂▁▊▊ ▒▆▌▊╺ ▌▊▊▚▗▌▊┻ ▊▎▝╴─▌╴▒▎▊  ┫▎▅▗┛▒   ▅▊▊ │  ▂▌ │ ▄▄━  ▁⎼ ╵
 ▊▂╵▗ ▎▁▖▆▃  ▗▁  ▄▂▃▌  ▎▌▊▄╴▊┃▌▌▊┃▊╵▁▁▊╹▂━▆▅ ▒▁▂▃╏▊▊▎┗▘▗▝▃▂▖ ▖╹ ▊▗┏▎━│▃▁▒▅▂▌ ╸╴▎
 ┓▂▗┛▃▃╴▆▂┏ ▄▄▂▁▆▅▂▃▎ ▒▎▃▌ ▗▎┃ ▂▂▖  ▇▖▇│╹▝▆▄▄ ▃▂▂▃▄▄▃▂▁▁▆▌▃▂▁▝▂▁▌▂▝▝▗▅▗▆▖─▆▘▌  ╵
▄▝▘╵▃ ▌▝▊▂▅▆▌▁▆▅▄▆▃▄▂▂▂▎▁▁▁▁▁ ▎⎽╹▊ ▌ ▘ ╸   ╵▆╵▗ ⎺ ▊│▆▒╵▁╹     ▘  ▄▘▊ ▇┏ ┏▃▁▁▘   
▅▄▆▆▆▅▆▆▇▇▝▊ ▄▆▄▃▁▅▂━▅┃▎▇━━▂╺▊▌▆▝  ┛▆▇▆▇    ╵  ▗ ▆▅ ▅▖⎽━▖╴ ╹╵   ╴╴  ╵╵  ╵▂▃┗━▆▂▄
▃ ▄▆▆▂▃▅▝▇▝▊┓▎▖╵▁▎ ▆▅▄╹▎▃▃▃▃▗▄▅▁▅   ▆╴  ╴╵    ▗ ▖    ▇▇▇▇▄ ▃  ▆⎺─│▘⎺   ▇ ⎻╵▆▆▅▄▝
▁⎼▄▄▅━▃┻▃▄╶▃▖▖▌▖ ┓ ▁╴⎺▌▌▃▃▃▊▊▁▁▁▁▂▃▃▄ ▄⎺ ╹▆╵▄  ⎻ ▚ ⎼─▃▄▅▄▆▆ ─ ─ ▄▃▂▂▁▂▅▄ ─ ▂▂   
▅▅▆▄▂━━━▄▄▄▄▝ ▌▅╵╴▊  ▒╺│▖▆╺ ▊▃▁▂▃⎻▂▅▅ ▅▂▁▃▂▂▃▃▆▃▃ ▚ ▂▁▁▂▁▁▁ ▆━▅━▆▒──⎼▇▊▄▃▃▆   ▄▃
━⎽⎽▂ ▅▃╺▄⎼─╵━   ┃▌  ⎼╸▝▘▒┓╵▃ ▆▄▃▂▆▄▇▇▇▄▅▄▅▘━▁▇▆▆┳▆ ▚ ▇▅▅▅⎺▃▃▃▃▂▃▁ ▄▆▆▆▅▅▅▅▅▇▆▅▄▅
⎻▁▁▂▂▃▄▃▄▄▃▅▅▎▌▗ ▌⎼ ▄▅▊╹▗▌▎▖▅▅▃▆▂▅▅▅▅▃▂▆▅▅▅▂▄▂▃▆▂┗▂ ▚ ▃▄▄▅▄▅▂▇▗▇▅ ▇▇▇▄ ▁▆▅━▇┻┳━▂
▘▂▂▂▇▅━▂▅▅▆▁⎽▌┓▖▗ ▒ ▇▆▊╵▂▗▝▘▊▄▁▂▃▄▂▆▂▄▂▅▂▗▖▂▆▆▃ ▒▖╴▅ ▝  ▂▁▃▆▂    ▖ ▆▅▁▊ ━▄▃▃▃━╸▅
▄▄▄▅▃▅▃─▇▁⎺ ▒▌▌  ▖▒▃╏▊ ▊▎┗▝▖▌ ▇ ▃▃ ▅▄▄▃▃▃▃▂▂▃▆▁⎽▆▄╵▅ ▝▝ ▗▇▁▁▁▊▃ ▁━ ▁▂▂ ▎▆⎼▂▂▃ ▁─
▗━▅ ▄▁▅▅▁▗⎼▁╵  ▗ ▎   ▎▘▊▎▊▂┓  ▗▁▆▁ ⎺▝⎼▚┓─╵⎼▄ ▘━▂╴─ ╺─ ▝▝ ▅▝▃▃▊ ▅ ▂▇▎╶╴▎▎▁▃╵ ▆▁▒▗
╶⎽▂▂⎽━▌⎺▃▆╵⎼┗▅▎│╵▎▁│ ▊┓  ▎▎▊▊▎▂▅│╴ ▆▒▆╺⎺ ▇▒▊▊ ╴▄─⎼▁▅▃▃▃▝▌▂┛▄▁▘▗ ▊ ▁▂▁ ▊ ⎻┓▁ ▃ ┗┓
▄▄▃▄▄━▄▄▂▊╴⎽▁▊ ▌⎻─  ╸ ▊▌▎ ▗┛ ▎▚ ╸ ▒▓┃▒▒╹  ▁▄ ▃▇▆▇▇╺╸ ╵━▅▝┓ ▅  ▊▘ ▃▂▂▃▝▁▂▄▃╹▒╹ ━▗
▆▅▅▄▅▆▆▄▁┛▅▝▁▃▎┃╵▒▂   ▌╵ ▁▊ ▗  ▒━▅▘│ ▄╴▃▒ ╵⎺ ─▒▅ ▁  ⎺▇⎽│▂▌ ▘ ▊▊▅  ╸▆⎽   ▘━▅━▅┳▎ 
▁▇⎻▝⎻▃▂▝▅ ▁▎▝▗  │⎽⎽▌▊▊▌╵╵▖▁▗ ▂┛▃▒▂▒▒╏⎺▁▘╏ ▅▖▊ ▇▒▁╏╴▗ ╵▊⎺  ▇▎┛┗ ▎╹    ▚▊ ⎼▃▃▁▄▁┳▅
━▎▄▖▅▄▃▆▅▇▆▆▄▎▘▎▇▅▃▂▎▗▘▌╵▗ ▊▃▂▂▁▁╴▝▆⎺▁─⎻╹▆▂▅▘╺▚▂ ▊▅ ▄▄▂ ▘╸▗ ▎▗  ━▃▅  ▊▊ ▖▆▒▂╴▗╴▒
▂▂▁▒▎ ▗▄▄▂▃▂▁▎⎺ ▊▄ ▄▂▄▗╵▌▄▁▝ ▁▁▃▃▅▅▇▆▆▅▄▃▃▃▅▅▁▆▆▃▆━▄▃▃ ▘ ▃ ▚▘▗▅▄▄▃▄▃▝  ▖▊▂▁▖▁  ▆
▅▌▃▇▆▄━ ▂▄▄▄▊▖▗▘▃▁▁▄▊▌▄╵│▌▂╵▎▝▂▗▄▃▄▅▄⎺▂▊▅▖━▅┗▅╸─▁▄▌▌▖  ▆▌▁ ▝▂┏▘╸▖ ▆▃▇  ▘▊▒▎ ╴╴▂╵
▇▂━▗▃▄ ▘╺▆▆▆▌▝▘▊▃▃▄━⎻  ▊ ▆▅▌▅▅▄▄▃▆▃▄▖▃▂▅▅▆▅▄▄▂▆▄▖━▃▌▖▌▊▎⎻━▁ ▘▎▎▄ ┓▁▊ ▗  ▂▒▂⎼▂╴▊▆
⎻▃▘▁⎺⎺▆▅▅▃▅▃▎╺▆⎻▄  ▆▊ ▆▊   ▃  ▅▆▃▆▆▌▄▅▖▌▂▃▃▆▊▊┗▊ ▆▃▊▄▗▅▃ ▖▌▊▆▅▊⎼▊╸ ▖  ▊ ▖▝▃▅▆▆╴ 
 ▆▒▆▆▇▃▌▊▌▌╵▌▎▖ ▅▆▆▃▌▝▃▂ ▅ ▁▌ ▆▅▆▃▂▁▂▁▂▃▁▆▅▄▘▅╸⎺┗▇▝▄▄ ▘▁▊▊▆▌▄ ▆▃ ▄▖▄▌ ▂▁▘┓▃▅▄▄▁▗
⎻ ▁▂ ▖ ▚⎻▆▗▃▌    ▁⎼▗ ▆▆▄▎▅▄▃─╺━  ▆▇▅▄▄▃▄▃▄▄▃━▅▅─▄▃▒▆▊ ▁▗   ▌ ▌▄▄▖▊▗▅ ▎▌▃▅▆▆▖▂▅▆▄
▂▆▆ ▆▆⎽▃▁▂▂▁▊ ▌⎽    ▖▁▁▗▎ ▘▌ ▆▅▝▎▊▎▚▅┛╶▝▄▆▄▆▅⎼▗ ▂ ▁▁ ▃▄ ▝▄▌▝▌▖▌▚  ▝ ▝▅▊▅▄╹▃▌▅▌ ▅
▌▖▅▅▎▝  ▄▃▅▄     ╴▁▂▘ ▌┗▎▎▂▌▖╴╺⎽ ▅▆▌ ▁▁▁▗╴▘▚▆▆ ━╺ ▃▃ ▆━▗ ▄ ▒▝▖▝ ▆▝ ▎▅▄▄▂▚▖▃▃▄━▎▗
▆▖─▖▝▌▝▄▄▃⎻ ▇▝▂▂▃▘▂ ▁▄▂ ▎▎▆▂▌▝▚▂ ▄ ▅▄▄╺ ▃▂ ▊▗▆▂▃▆▁▝▄▂ ▆⎺ ━ ▖▊▊  ▝▃▘▝▃▄╸▘▌▎▁┏▌▂▎ 
▁┓▚▅▄━▗▒▁▄▇▅▂▆▝▆▆▇   ▆━╸▌▎▄▌▎▇▆┏ ▂▘▁▂ ▒▁▅│▝▆▖▝▂┏▄▁▂▄▄▒▂▆▆  ▄▃ ▅▂▅ ▆▄▇▘▎▂▂▂▅▆▄▄▂▄
▃▄▅╸▘╺▅▅▇▆▅▂▒▁▃ ▇▁▆▅▚▌┓▗▌▌▄▁▘┏▘▇ ▘▒▅▊▒▆▄▅▅▄━▖┗▘ ▘▅╵▝┗▅▂▆▄▌▇▅▂┻▄▃▃▃▄▅▖▄▁▆▅▆╵▂▆▂▁▂
▅▇▆▅⎻▗▂▃▇▊┛▊▌▇▅▄▃▝▁▖▅ ▊▆▌▌▎▅╺━▖▃▅▂▘▘▝▃╴▂▎▘▊▊┃▂┻╸╶━⎽▁▁▂▂▁▁ ▂▂▃▖ ▃▂ ▊╵ ▄▆▊▘▁▊⎼▌▃▆▝
┓▁▁▄ ▃⎺▆▒▅▄▃▃▁━▅ ─▅▄▃▅▆▂▊▌▁▁⎽━▃▃▆▆▌ ▃━▁┗▂▘╹▊▁▇▎▂▅┃▇▆▆▄▌ ━▂▘   ▎▖▎▃▘▁▁ ▃ ▄▂▃▂▊▘⎼│
▂⎻▅▂▁▁▆▆▁ ▂╹▗▚⎺━▂▁▂▂▃ ▅┗▊▌▃▅▁▌▅ ▃▗▅┗▆▂▗━▅┗▄▝▅  ▗▂╸▂▁▂▊ ╸▁▅▝▊▌ ▅╺▃▄▗▆ ▗╏╵▖▃▃▃▌▄▗▚
▘▒▂▄▒╸▃▅▂╏▘━▃▄▆▅▅▆▅▄▂▄▃─ ▊▎╺▇▅▇▝ ┏━⎼╴▆▂▌▌▅▖▊▌▆▝▄▆▁ ╴▗╺▁▅▁▖▁▝▇▅▃▂▄▂⎼   ▌ ▆▊▃▅▄╸▗━
 ▝▝▃╴▇▗▂▃▄ ▄▊ ▃▄▄▄▄▄▄▄▄╴▅╵▎▃╹▁ ▃▘▅▅▆▌▄▗▂╵▘▝▅▚▄ ▃▄╸╶▃▂▃▘━▄▅▖▆▇▇▂▆▆▇▆ ▄▘▃▃▃▁▅▌▌▎▅▊
▂▂╵▄▘▆▅▇▇▅▆▊▂▃▃▖▌▌│▅▖ ▃ ▂▗▎▖▝▂▌▂▃▅⎻▝▅▆ ▆┏▂▃┓▘▒▌▂▄▄▁▅▅▅▁▆▊▁▌ ▆┏▌▊▅▄▅▄▅▅▇ ▆▃▎▝▄▘▘ 
▗▆▆▆ ▎▌▄▘▇┓╵▄▃┓▌▁▝▝ ▃▁▂  ▅  ▇ ━▄▘▂▂▃▄▄▄▄▅▃▆┃▖▌▌▊▁▂▃▄━─▖ ▄╴▖▗▆▂╹▄▄▃▁ ╴▝▅▅▆▂▅▁▄▅╵▃
▂▁ ─▝ ┻▅▊▇▅ ┛ ▁▁▂▁▁▁▃▃▝▁▂▆▒▅▖▄▅▄▘▃▘╺▁⎽▖▄▄▗⎻▅▇▒┃▃▄▄▄▘▄─▝▄▁▆▃▇▄▂▂▁╴╹▅▆▁▂▂▃▅▇▇▂▃▄▅━
▂▅▆▄▅─▅▄▃▄╴▅▄▅▆▇▄▂▆▄▄▅━━▂▂─▁▁▂━▆▊▆▃▊⎼▗▘▇▝▌▚▌▃▂▘▁▚▆┓━▄▅▆▅▅▘▘▗▁ ▒▅▂▃▄▆━▃▄▆━▂▂▅▅▇▂▂
▅╸╵▂▎▝▅▖──▒━▗▃▘▝▁▝▊▁▂▁▚▄▄▝╺━▄▌▁ ▊▌▅▁▆▆▅▄▃▂▄─▊━▂▗▃ ▁ ┃▝▂▂▁▂▁▌▃╋▂ ▗▄▂▄▄┏▁▄▂▂▃▃▅▅┃▄
┛▅▂▆▅▖▃╸▝▆▅▅▅▆ ▒╶▄▆▌▅▆▘▌▗▄▄▄▂▁▝▃▂┓╺ ▄▃▅▅┛▃▒▃▒▄▂▊▂▅▄▌▅▂▄▆▂▃▘▁▌▎⎻▅▁▆▄▆▃▅▎▆▂▃━╴ ▌▂╵
▎ ▅▃▃▂▂▃▃ ╹▂▃▌▗▃▒▇  ▎▗▄▌▝▂▎▁▘▂┓─▄▂▂▄▄▄▅▄━▎▄▆▃━╹▎▌▅▅┏▝▄▆▃▁▅─▂▆▆▄▅▅▅━▎▄▆▗▎▄▃▆▂▄⎼┗▃
╵╹▝▁▘⎼╏ ▂▂╴ ▝ ▝▄▅▃▎╴▆▃┗⎼▂▅▅╴▌│▘▗▁▝ ▎▅▄▅▊▒▂▒▂⎽▆▇▚▒▊ ▃▃▂▁▃▖▖▗▅▖┛▄▅ ▘┓▄▄▂▄▘▁▄╵▊▃▎┗⎼
▄▂▂▃▂▃▎▝▂▄▃╵▇ ▂▊▄▁▌▂▂▂▄▌▖▂ ▄▎▊▂▅─▆▄▂▄▃▆▚▁▃⎺▄▆▂▚╶▄▊▅▂▄▃▆▄▖▘▗▇▁▌▊▘▆▁▂▁▊ ▗▆╴▂▗▂╵▄▇▌
⎽▄▅▆▖━▃━▒▂▅┳╴▁━▂▂▂▆ ┻▄▁▊╺━⎼▂ ▃▚▂ ▊ ▄▄▆▆▄  ╴▁ ▊▂▂▗▅▂⎼▃▂▅▄▗▄▂▆▌▆▊▄▎╴▆▅▆╴ ▒┛▂▆⎻▂▌▌▝
▂▁▁▝▆▁ ▅▆━▃▆▇⎻▄▄▆▇┓│━▂▆ ▅▁│▖▂▎▌╏▌▝ ▄▃▆━▄▘▃▃▄▖▌▝▘▂▌▗▗▄▁▁ ▌▃▁▌ ┃▃▄▗▃▊▂▝ ▁ │▅┏▂╴▅▂▊
▎▆▅▄▌▃▃▂▎▄┏▄▆▁▗▂▖▂▁▅▒▊▃▃▃▄▃▂▃▂▁ ╸▎▇▁▅▃▂▁━▘╵━▒▊▎▌▆▃▄▇▇▇▗▂ ▆┏ ▎▂▄▁ ▃▝▎▎▃▆▅╏▇▂▂┏▄▄▂
▂▅▊▃▌▃╵▂▂▄▄▆▇▄▃▄▇▄▄▄▂▌╺▅▃▂▌▝▘▗▂▇▅▂▃▄━▂▌▝━▎▂╏▂▘▗ ▊▊⎽ ▗▂▒╸╵▃▅▁▂▄▖▎▊▗▄▒▎▌ ▄╏▂▎▃▘▌ ▃
▃▂▆▆▇▌▘ ▇▎▊▗▄┓▂▂▁▝▘▌▘ ▁▌▂╸▆▂▊▂┓▃▃▖▊▆▆▃▚▃▒▁▂▃▎ ▎▂▊▄▅▌▌▝▂▅▆▖ ▝▒▃▅╸▌▁▁━▂▄▅━━▅▘▁▁▝▄▂

real    0m0.796s
user    0m1.324s
sys 0m0.060s
$ time java TerminalImageViewer -h 100 a.jpg > log

real    0m0.773s
user    0m1.248s
sys 0m0.036s
$ time cat log
⎼▁▇ ▝ ▎▅▇▇▇▆▅━▃▁ ▊╴▇▗┛ ▒▁▂▄▆ ▇━▝▗╴    ▗ ▄╴ ⎽▁▃▒▖╵▊ ▇  ▁▊▘▘▘▎ ╸▁▁─    ▝ ╹▃▒▅▁▃▄▆▄
▘▆▄▎▝▌┗┃ ⎽▅ ╶  ▅─▒▆▆▅ ▅▅▅▅▒▝▃╶▅ ▇▇⎼▁ ⎻╵  ⎻▚▂▂▃▂▃▘ ▎▗⎻▅▎▂▂▄▘╺ ⎼▒━▅    ▝▗━▃▆▗▖ ▝╹╴
 ▃▁ ▊ ╵▆  ▃▅▂┗▒▖ ▆▇▅▌▁ ▃▄▂▃▅  ╴▄▄▘  ▊━▊ ┛┛┛▎⎻⎺╵▒⎺╶╴┓▅▅▆▄━▅ ╺▄▃╵╵ ┓   ▌▅▁▌ ▁╵▎▁▁⎽
┛▗▅ ▊▘╹╺ ╴┛╶   ▁▚▎▇▁▂▆▝ ▄▄▃ ▂▁▄▅▃ ⎽⎼⎼▃▖ ▁▒▇  ▇┗▗╴╴▒─▅▃▒▆▖╵▒╵▒▃▒┗┓▗ ▊▘ ▆ ┻━▆▅▒▁▆▘
⎼▇▒▎▎  ▁▊ ▃ ╵▆⎻▝▌▅▊▂▌┗▄▄▂▂▅▇▂▚╴▊⎽╺ ╴ ▝⎻▄━▆▅▒▁━▂▅╵▂▂⎽▂▝▌▒▒   ▃▒╵▆╴▌▁▘╴╴  ┃▗▖  ▇─╴
 ╵⎼ ▁ ▎╵ ▁    ╵▊▚━▊▗▘━─▄ ▊▘⎺▂▁ ▊⎽│▂⎼⎼▌▖▗▄▒▂╹▃▊▅▆ ▎▇▅╏    ▒ ▎▘▄▄⎺▆▂╴╺╵▂▒╶╴▆ ⎺╶▁⎽╺
╹ ▇▘  ▒┓╶╴  ┏▃▆ ▒ ╺▅▒▅╶▁╹─╴▄    ▃▅▇⎼⎼│ ▝─━╴▝┗▆┗⎻ ━╴▊▒▇╸ ▁▃  ▁╵▘▊▁▊╴▗▂▃▖⎼▊▆⎼▃▂▂  
╴▁▄▘⎻▇▂▚▃ ▆│ ▃━▎ ╵▆▅▆  ╺│ ▒ ╴╴ ╺   ▗ ╵▘▝▁▒▅▖▁╋   ▄▝⎼▁ ╴     ▆▆▅▆▒▁▊▄▅▘ ⎺⎺╺▅▁▇▄▄▄
▒ ▃▝ ▝▇▊╸  ╵  ╴▘▅  ─▝  ▁▊⎼    ▎╸▘╺▁▝ ▝▌▝▂▒▁▚╸▃▘▝▊▘▄░▖╸▆╺    ╺⎽╏▂╵▝ ╺ ▃ ▁⎽  ▆▖▌ ▗
▝▅▃┛▃╺⎻▊▎─▄┗   ▌▁▂ ▁ ▁▇▇▝⎻ ▆ ▊━╴  ╴▆▅▃▊▂▃▚▘▇⎽▊┛▘ ╏▒▂▁⎼ ▂   ╴╴▆╴ ▆ ▅▅╸▇ ▂▃▘▁▄┻▄▂▆
╴▖╴▃ ▊ ┃▘▘ ┃▂ │  ▁▅▌⎺ ▊╸▊  ▇ ╸╵  ▆⎻⎺▒╴ ┗ ▒⎻▄▅ ▒▎  ▒  ▄⎻─▘⎺▆╵╶ ⎽ ⎽ ▄▆▁▃▄▆▇┗▘▗▃▌╴▁
┗  ▄ ▒╵▒▌│▇│━  ▅┗▘▆ ▆▅▆▝▖    ╴▊ ░▁▂▘▂▒━ ▒▝ ▌▅▅▎  ▎▂▒╴╶⎼╵▎ ╴ ─ ▘ ╹  ╸▅▃⎼▃▄▄▗▚  ▅▝
╵▄ ╺  ╸╴▊    ╏ ││▌▖▖ ─▁    ▁▃⎼╺▒─▅▄▆▊│ ╸▃╴╺ ▃▒ ▂╴▅⎺▚╴ ━⎻  ▂╵╴ ╵ ━▎  ╺╴▆▅▄▘┃▅   ╺
╸╴─  ─▒┏▒┛ ▌▖▂ ▘▌▃▂▁▁▗▅▗╴╸╸ ╺▁│ ▄ ▎▝▇▒⎻▄▚▒ ▁╶┓▗ ▗▂╵    ▗ ▗─⎼ ▆╴─▒▗▖ ▁▁▆▇ ▗ ┫▒━╹⎽
┫▒▎▁  ╴▘▖┃╵▃▇▘▝▆ ▄▎▄▝▆▎▆┃▎╏ ▁▁│╵ ▃▖─▎╵ ▒━⎽▂▁ ⎺▌╵─▇▚╵╴╵ ╸╵  ╺ ─⎺▇▒ ╵ ▇┏▅⎻━▂▆┓ ▂━━
▇ ╏╺ ▆⎽▊▇╺▄ ▅ ▗▂▊  ▅▄▊▌▅▁▖▊▃━▄┗│▁  ▚⎺▎╴▒    ╴╴╺▒▒ ▊▁━│▒▎ ╵╴  ╵▁╴    ⎺⎼   ▆▃━ ▝▊ 
  ▅┏ ▊  ▒▘▗▆▝▝▆▖▖ ▊▄▂▌  ▝▄▊▂━─▎ ╶╹╶▄╏┗▆ ▇▅⎽▇⎻━━─╺▒▊▊▅▎  ▊▒▁ ╴ ╴⎺ ▄ ▒▇▁▁▂┗⎽▘ ▌┏─▒
▌╸▇▆ ▊━   ▘▗╸▝▌▗▃▘ ▗▅   ▅▁▖▌ ▁▌ ╏▎╹  ▂▖━▝▖╴╴▝│ ▒┗▚┏▌⎼▅▁▊▒▒╏▒⎺╵   ▂▊▅▆▇ ▂ ▎━ ▂▃╴⎼
▎▁┏━  ▚┣▊┛▃┓▌▅▄▌▆ ▅ ▅▃▃▄▗▖  ▆▅▖ ▊│▘   ▝▂ ▊    ▆ ▌▌│▎▖▗▇╵▆┃▊▊  ╶▃ ⎽    ▇▒⎻╵╹ ▘│▌ 
⎽▄▅▖  ╏▌   ▊╺▃ ▘▃▊ ▝ ▄╶ ▖ ▚ ▊▆▆ ▘ ▇▗  ▊▆▝▒▃⎼╴▆▗ ▒ │▎▂▗┏▎╴▒░╸ ─ ╵ ▚╴▁  ⎽▌▎⎻ ▁▖▅▎▇
╺▒▒┃╸╵▃▂▂▎┏▘▁▂ ▖▁ ▝▃▁▗▖▅ ▂ ┓ ▄▆ ▘▃ ▗▅▎▊⎺╹▂ ▘ ▌▖▁╏▘─▒│▗▁╴  ▝▄▊▌▎ ━ ▗▂⎺╴▁▅─▗▗▆─   
▁▘▂▊▎ ▎▊▇▎▂▖▝▆ ▎ ▂⎼▆▎▊▌━ ▄┗▊▚▖▖▗▗▂│▊╸▎▊▇▅┗▃▁▗▄▎▌│╺┃━▘┏▇─⎺▆▁▗▊┃▎ ▊ ▅▖▎▅╹▒▃ ┗  ▊╸ 
╴▝▆▊▎ ▎▆ ▄▅ ▇▆ ▌▇▌ ▁▊ ▊▆▌▝─ ▚ ▌ ▎┃│▊▂ ▊  ▎▄▌▎▄▎ ╸▝▃▘▒▎ ▖▒╴▝▘▊▆▎▒▒▂▖▎▁▒▄▄▒▖╶▊ ▄ ▂
  ▊   ▎╺▎┗▎╵▃▂   ▁▂▁▊▊ ▒▆▌▊╺ ▌▊▊▚▗▌▊┻ ▊▎▝╴─▌╴▒▎▊  ┫▎▅▗┛▒   ▅▊▊ │  ▂▌ │ ▄▄━  ▁⎼ ╵
 ▊▂╵▗ ▎▁▖▆▃  ▗▁  ▄▂▃▌  ▎▌▊▄╴▊┃▌▌▊┃▊╵▁▁▊╹▂━▆▅ ▒▁▂▃╏▊▊▎┗▘▗▝▃▂▖ ▖╹ ▊▗┏▎━│▃▁▒▅▂▌ ╸╴▎
 ┓▂▗┛▃▃╴▆▂┏ ▄▄▂▁▆▅▂▃▎ ▒▎▃▌ ▗▎┃ ▂▂▖  ▇▖▇│╹▝▆▄▄ ▃▂▂▃▄▄▃▂▁▁▆▌▃▂▁▝▂▁▌▂▝▝▗▅▗▆▖─▆▘▌  ╵
▄▝▘╵▃ ▌▝▊▂▅▆▌▁▆▅▄▆▃▄▂▂▂▎▁▁▁▁▁ ▎⎽╹▊ ▌ ▘ ╸   ╵▆╵▗ ⎺ ▊│▆▒╵▁╹     ▘  ▄▘▊ ▇┏ ┏▃▁▁▘   
▅▄▆▆▆▅▆▆▇▇▝▊ ▄▆▄▃▁▅▂━▅┃▎▇━━▂╺▊▌▆▝  ┛▆▇▆▇    ╵  ▗ ▆▅ ▅▖⎽━▖╴ ╹╵   ╴╴  ╵╵  ╵▂▃┗━▆▂▄
▃ ▄▆▆▂▃▅▝▇▝▊┓▎▖╵▁▎ ▆▅▄╹▎▃▃▃▃▗▄▅▁▅   ▆╴  ╴╵    ▗ ▖    ▇▇▇▇▄ ▃  ▆⎺─│▘⎺   ▇ ⎻╵▆▆▅▄▝
▁⎼▄▄▅━▃┻▃▄╶▃▖▖▌▖ ┓ ▁╴⎺▌▌▃▃▃▊▊▁▁▁▁▂▃▃▄ ▄⎺ ╹▆╵▄  ⎻ ▚ ⎼─▃▄▅▄▆▆ ─ ─ ▄▃▂▂▁▂▅▄ ─ ▂▂   
▅▅▆▄▂━━━▄▄▄▄▝ ▌▅╵╴▊  ▒╺│▖▆╺ ▊▃▁▂▃⎻▂▅▅ ▅▂▁▃▂▂▃▃▆▃▃ ▚ ▂▁▁▂▁▁▁ ▆━▅━▆▒──⎼▇▊▄▃▃▆   ▄▃
━⎽⎽▂ ▅▃╺▄⎼─╵━   ┃▌  ⎼╸▝▘▒┓╵▃ ▆▄▃▂▆▄▇▇▇▄▅▄▅▘━▁▇▆▆┳▆ ▚ ▇▅▅▅⎺▃▃▃▃▂▃▁ ▄▆▆▆▅▅▅▅▅▇▆▅▄▅
⎻▁▁▂▂▃▄▃▄▄▃▅▅▎▌▗ ▌⎼ ▄▅▊╹▗▌▎▖▅▅▃▆▂▅▅▅▅▃▂▆▅▅▅▂▄▂▃▆▂┗▂ ▚ ▃▄▄▅▄▅▂▇▗▇▅ ▇▇▇▄ ▁▆▅━▇┻┳━▂
▘▂▂▂▇▅━▂▅▅▆▁⎽▌┓▖▗ ▒ ▇▆▊╵▂▗▝▘▊▄▁▂▃▄▂▆▂▄▂▅▂▗▖▂▆▆▃ ▒▖╴▅ ▝  ▂▁▃▆▂    ▖ ▆▅▁▊ ━▄▃▃▃━╸▅
▄▄▄▅▃▅▃─▇▁⎺ ▒▌▌  ▖▒▃╏▊ ▊▎┗▝▖▌ ▇ ▃▃ ▅▄▄▃▃▃▃▂▂▃▆▁⎽▆▄╵▅ ▝▝ ▗▇▁▁▁▊▃ ▁━ ▁▂▂ ▎▆⎼▂▂▃ ▁─
▗━▅ ▄▁▅▅▁▗⎼▁╵  ▗ ▎   ▎▘▊▎▊▂┓  ▗▁▆▁ ⎺▝⎼▚┓─╵⎼▄ ▘━▂╴─ ╺─ ▝▝ ▅▝▃▃▊ ▅ ▂▇▎╶╴▎▎▁▃╵ ▆▁▒▗
╶⎽▂▂⎽━▌⎺▃▆╵⎼┗▅▎│╵▎▁│ ▊┓  ▎▎▊▊▎▂▅│╴ ▆▒▆╺⎺ ▇▒▊▊ ╴▄─⎼▁▅▃▃▃▝▌▂┛▄▁▘▗ ▊ ▁▂▁ ▊ ⎻┓▁ ▃ ┗┓
▄▄▃▄▄━▄▄▂▊╴⎽▁▊ ▌⎻─  ╸ ▊▌▎ ▗┛ ▎▚ ╸ ▒▓┃▒▒╹  ▁▄ ▃▇▆▇▇╺╸ ╵━▅▝┓ ▅  ▊▘ ▃▂▂▃▝▁▂▄▃╹▒╹ ━▗
▆▅▅▄▅▆▆▄▁┛▅▝▁▃▎┃╵▒▂   ▌╵ ▁▊ ▗  ▒━▅▘│ ▄╴▃▒ ╵⎺ ─▒▅ ▁  ⎺▇⎽│▂▌ ▘ ▊▊▅  ╸▆⎽   ▘━▅━▅┳▎ 
▁▇⎻▝⎻▃▂▝▅ ▁▎▝▗  │⎽⎽▌▊▊▌╵╵▖▁▗ ▂┛▃▒▂▒▒╏⎺▁▘╏ ▅▖▊ ▇▒▁╏╴▗ ╵▊⎺  ▇▎┛┗ ▎╹    ▚▊ ⎼▃▃▁▄▁┳▅
━▎▄▖▅▄▃▆▅▇▆▆▄▎▘▎▇▅▃▂▎▗▘▌╵▗ ▊▃▂▂▁▁╴▝▆⎺▁─⎻╹▆▂▅▘╺▚▂ ▊▅ ▄▄▂ ▘╸▗ ▎▗  ━▃▅  ▊▊ ▖▆▒▂╴▗╴▒
▂▂▁▒▎ ▗▄▄▂▃▂▁▎⎺ ▊▄ ▄▂▄▗╵▌▄▁▝ ▁▁▃▃▅▅▇▆▆▅▄▃▃▃▅▅▁▆▆▃▆━▄▃▃ ▘ ▃ ▚▘▗▅▄▄▃▄▃▝  ▖▊▂▁▖▁  ▆
▅▌▃▇▆▄━ ▂▄▄▄▊▖▗▘▃▁▁▄▊▌▄╵│▌▂╵▎▝▂▗▄▃▄▅▄⎺▂▊▅▖━▅┗▅╸─▁▄▌▌▖  ▆▌▁ ▝▂┏▘╸▖ ▆▃▇  ▘▊▒▎ ╴╴▂╵
▇▂━▗▃▄ ▘╺▆▆▆▌▝▘▊▃▃▄━⎻  ▊ ▆▅▌▅▅▄▄▃▆▃▄▖▃▂▅▅▆▅▄▄▂▆▄▖━▃▌▖▌▊▎⎻━▁ ▘▎▎▄ ┓▁▊ ▗  ▂▒▂⎼▂╴▊▆
⎻▃▘▁⎺⎺▆▅▅▃▅▃▎╺▆⎻▄  ▆▊ ▆▊   ▃  ▅▆▃▆▆▌▄▅▖▌▂▃▃▆▊▊┗▊ ▆▃▊▄▗▅▃ ▖▌▊▆▅▊⎼▊╸ ▖  ▊ ▖▝▃▅▆▆╴ 
 ▆▒▆▆▇▃▌▊▌▌╵▌▎▖ ▅▆▆▃▌▝▃▂ ▅ ▁▌ ▆▅▆▃▂▁▂▁▂▃▁▆▅▄▘▅╸⎺┗▇▝▄▄ ▘▁▊▊▆▌▄ ▆▃ ▄▖▄▌ ▂▁▘┓▃▅▄▄▁▗
⎻ ▁▂ ▖ ▚⎻▆▗▃▌    ▁⎼▗ ▆▆▄▎▅▄▃─╺━  ▆▇▅▄▄▃▄▃▄▄▃━▅▅─▄▃▒▆▊ ▁▗   ▌ ▌▄▄▖▊▗▅ ▎▌▃▅▆▆▖▂▅▆▄
▂▆▆ ▆▆⎽▃▁▂▂▁▊ ▌⎽    ▖▁▁▗▎ ▘▌ ▆▅▝▎▊▎▚▅┛╶▝▄▆▄▆▅⎼▗ ▂ ▁▁ ▃▄ ▝▄▌▝▌▖▌▚  ▝ ▝▅▊▅▄╹▃▌▅▌ ▅
▌▖▅▅▎▝  ▄▃▅▄     ╴▁▂▘ ▌┗▎▎▂▌▖╴╺⎽ ▅▆▌ ▁▁▁▗╴▘▚▆▆ ━╺ ▃▃ ▆━▗ ▄ ▒▝▖▝ ▆▝ ▎▅▄▄▂▚▖▃▃▄━▎▗
▆▖─▖▝▌▝▄▄▃⎻ ▇▝▂▂▃▘▂ ▁▄▂ ▎▎▆▂▌▝▚▂ ▄ ▅▄▄╺ ▃▂ ▊▗▆▂▃▆▁▝▄▂ ▆⎺ ━ ▖▊▊  ▝▃▘▝▃▄╸▘▌▎▁┏▌▂▎ 
▁┓▚▅▄━▗▒▁▄▇▅▂▆▝▆▆▇   ▆━╸▌▎▄▌▎▇▆┏ ▂▘▁▂ ▒▁▅│▝▆▖▝▂┏▄▁▂▄▄▒▂▆▆  ▄▃ ▅▂▅ ▆▄▇▘▎▂▂▂▅▆▄▄▂▄
▃▄▅╸▘╺▅▅▇▆▅▂▒▁▃ ▇▁▆▅▚▌┓▗▌▌▄▁▘┏▘▇ ▘▒▅▊▒▆▄▅▅▄━▖┗▘ ▘▅╵▝┗▅▂▆▄▌▇▅▂┻▄▃▃▃▄▅▖▄▁▆▅▆╵▂▆▂▁▂
▅▇▆▅⎻▗▂▃▇▊┛▊▌▇▅▄▃▝▁▖▅ ▊▆▌▌▎▅╺━▖▃▅▂▘▘▝▃╴▂▎▘▊▊┃▂┻╸╶━⎽▁▁▂▂▁▁ ▂▂▃▖ ▃▂ ▊╵ ▄▆▊▘▁▊⎼▌▃▆▝
┓▁▁▄ ▃⎺▆▒▅▄▃▃▁━▅ ─▅▄▃▅▆▂▊▌▁▁⎽━▃▃▆▆▌ ▃━▁┗▂▘╹▊▁▇▎▂▅┃▇▆▆▄▌ ━▂▘   ▎▖▎▃▘▁▁ ▃ ▄▂▃▂▊▘⎼│
▂⎻▅▂▁▁▆▆▁ ▂╹▗▚⎺━▂▁▂▂▃ ▅┗▊▌▃▅▁▌▅ ▃▗▅┗▆▂▗━▅┗▄▝▅  ▗▂╸▂▁▂▊ ╸▁▅▝▊▌ ▅╺▃▄▗▆ ▗╏╵▖▃▃▃▌▄▗▚
▘▒▂▄▒╸▃▅▂╏▘━▃▄▆▅▅▆▅▄▂▄▃─ ▊▎╺▇▅▇▝ ┏━⎼╴▆▂▌▌▅▖▊▌▆▝▄▆▁ ╴▗╺▁▅▁▖▁▝▇▅▃▂▄▂⎼   ▌ ▆▊▃▅▄╸▗━
 ▝▝▃╴▇▗▂▃▄ ▄▊ ▃▄▄▄▄▄▄▄▄╴▅╵▎▃╹▁ ▃▘▅▅▆▌▄▗▂╵▘▝▅▚▄ ▃▄╸╶▃▂▃▘━▄▅▖▆▇▇▂▆▆▇▆ ▄▘▃▃▃▁▅▌▌▎▅▊
▂▂╵▄▘▆▅▇▇▅▆▊▂▃▃▖▌▌│▅▖ ▃ ▂▗▎▖▝▂▌▂▃▅⎻▝▅▆ ▆┏▂▃┓▘▒▌▂▄▄▁▅▅▅▁▆▊▁▌ ▆┏▌▊▅▄▅▄▅▅▇ ▆▃▎▝▄▘▘ 
▗▆▆▆ ▎▌▄▘▇┓╵▄▃┓▌▁▝▝ ▃▁▂  ▅  ▇ ━▄▘▂▂▃▄▄▄▄▅▃▆┃▖▌▌▊▁▂▃▄━─▖ ▄╴▖▗▆▂╹▄▄▃▁ ╴▝▅▅▆▂▅▁▄▅╵▃
▂▁ ─▝ ┻▅▊▇▅ ┛ ▁▁▂▁▁▁▃▃▝▁▂▆▒▅▖▄▅▄▘▃▘╺▁⎽▖▄▄▗⎻▅▇▒┃▃▄▄▄▘▄─▝▄▁▆▃▇▄▂▂▁╴╹▅▆▁▂▂▃▅▇▇▂▃▄▅━
▂▅▆▄▅─▅▄▃▄╴▅▄▅▆▇▄▂▆▄▄▅━━▂▂─▁▁▂━▆▊▆▃▊⎼▗▘▇▝▌▚▌▃▂▘▁▚▆┓━▄▅▆▅▅▘▘▗▁ ▒▅▂▃▄▆━▃▄▆━▂▂▅▅▇▂▂
▅╸╵▂▎▝▅▖──▒━▗▃▘▝▁▝▊▁▂▁▚▄▄▝╺━▄▌▁ ▊▌▅▁▆▆▅▄▃▂▄─▊━▂▗▃ ▁ ┃▝▂▂▁▂▁▌▃╋▂ ▗▄▂▄▄┏▁▄▂▂▃▃▅▅┃▄
┛▅▂▆▅▖▃╸▝▆▅▅▅▆ ▒╶▄▆▌▅▆▘▌▗▄▄▄▂▁▝▃▂┓╺ ▄▃▅▅┛▃▒▃▒▄▂▊▂▅▄▌▅▂▄▆▂▃▘▁▌▎⎻▅▁▆▄▆▃▅▎▆▂▃━╴ ▌▂╵
▎ ▅▃▃▂▂▃▃ ╹▂▃▌▗▃▒▇  ▎▗▄▌▝▂▎▁▘▂┓─▄▂▂▄▄▄▅▄━▎▄▆▃━╹▎▌▅▅┏▝▄▆▃▁▅─▂▆▆▄▅▅▅━▎▄▆▗▎▄▃▆▂▄⎼┗▃
╵╹▝▁▘⎼╏ ▂▂╴ ▝ ▝▄▅▃▎╴▆▃┗⎼▂▅▅╴▌│▘▗▁▝ ▎▅▄▅▊▒▂▒▂⎽▆▇▚▒▊ ▃▃▂▁▃▖▖▗▅▖┛▄▅ ▘┓▄▄▂▄▘▁▄╵▊▃▎┗⎼
▄▂▂▃▂▃▎▝▂▄▃╵▇ ▂▊▄▁▌▂▂▂▄▌▖▂ ▄▎▊▂▅─▆▄▂▄▃▆▚▁▃⎺▄▆▂▚╶▄▊▅▂▄▃▆▄▖▘▗▇▁▌▊▘▆▁▂▁▊ ▗▆╴▂▗▂╵▄▇▌
⎽▄▅▆▖━▃━▒▂▅┳╴▁━▂▂▂▆ ┻▄▁▊╺━⎼▂ ▃▚▂ ▊ ▄▄▆▆▄  ╴▁ ▊▂▂▗▅▂⎼▃▂▅▄▗▄▂▆▌▆▊▄▎╴▆▅▆╴ ▒┛▂▆⎻▂▌▌▝
▂▁▁▝▆▁ ▅▆━▃▆▇⎻▄▄▆▇┓│━▂▆ ▅▁│▖▂▎▌╏▌▝ ▄▃▆━▄▘▃▃▄▖▌▝▘▂▌▗▗▄▁▁ ▌▃▁▌ ┃▃▄▗▃▊▂▝ ▁ │▅┏▂╴▅▂▊
▎▆▅▄▌▃▃▂▎▄┏▄▆▁▗▂▖▂▁▅▒▊▃▃▃▄▃▂▃▂▁ ╸▎▇▁▅▃▂▁━▘╵━▒▊▎▌▆▃▄▇▇▇▗▂ ▆┏ ▎▂▄▁ ▃▝▎▎▃▆▅╏▇▂▂┏▄▄▂
▂▅▊▃▌▃╵▂▂▄▄▆▇▄▃▄▇▄▄▄▂▌╺▅▃▂▌▝▘▗▂▇▅▂▃▄━▂▌▝━▎▂╏▂▘▗ ▊▊⎽ ▗▂▒╸╵▃▅▁▂▄▖▎▊▗▄▒▎▌ ▄╏▂▎▃▘▌ ▃
▃▂▆▆▇▌▘ ▇▎▊▗▄┓▂▂▁▝▘▌▘ ▁▌▂╸▆▂▊▂┓▃▃▖▊▆▆▃▚▃▒▁▂▃▎ ▎▂▊▄▅▌▌▝▂▅▆▖ ▝▒▃▅╸▌▁▁━▂▄▅━━▅▘▁▁▝▄▂

real    0m0.018s
user    0m0.000s
sys 0m0.004s

Nothing is rendered at all for very small images at full size

Given the attached files, I'd expect some sort of output, but tiv reports nothing.

./tiv -f 1x1.png 2x2.png 3x3.png 4x4.png 5x5.png 

5x5
4x4
3x3
2x2
1x1

I believe this applies to any image less than 8 pixel tall or 4 pixels wide. Ideally, something should be rendered for these tiny images.

I'm imaging two options:

My initial thought was to rescale the image so it's at least 4x8. This commit does exactly that. It's the only commit on the branch fix-tiny.

However, I'm now thinking of a different approach: If the image is smaller than target window in both directions, scale up to fill the space, but limit the scale to the the largest integer that won't cause the image to exceed the allotted space. Also use nearest neightbor interpolation. The result should provide larger "pixels". On the down side, this approach won't work for images that are very narrow but tall or very wide but short. That may yet require special case logic.

STDIN?

How much of a pain would it be to take input from stdin?

image line shifting

All of the images I view have the same problem - lines of shifted data. I am running OSX 10.11.6 with java 1.8.0_111

screen shot 2016-12-22 at 9 37 18 pm

2012-05-29 20-28

Compilation fails with Cygwin on Windows 7 SP1

I followed the install instructions in the readme, but running "make" gave me a bunch of errors relating to pclose(file) and failed (I can paste the log if need be). I git checked out commit d543b3b and after going through the same steps found that it compiles just fine. After looking at a git diff between d543b3b and master I noticed some differences in the makefile. Namely, the parameter std=c++11 was added on commit 9ec066f. So I reset back to master, removed the -std=c++11 option, and compiled successfully.

It looks like that option was added to fix compilation on mac and Linux, but it seems to break it on windows. I don't know much about programming so I'm not sure if there's a different way to set the standard and fix compatibility with all OS's, but it looks like there may need to be a windows only branch with that option removed.

Here's exactly what I did to fix my error:

diff --git a/src/main/cpp/Makefile b/src/main/cpp/Makefile
index 2cd121f..3a8602d 100644
--- a/src/main/cpp/Makefile
+++ b/src/main/cpp/Makefile
@@ -1,7 +1,7 @@
 default: tiv

 tiv.o: tiv.cpp CImg.h
-       g++ -std=c++11 -Wall -fexceptions -O2 -c tiv.cpp -o tiv.o
+       g++ -Wall -fexceptions -O2 -c tiv.cpp -o tiv.o

 tiv : tiv.o
        g++ tiv.o -o tiv -pthread -s

Strange characters in terminal

tiv only works halfway as expected when using the -256 option. But even then I can see strange characters inside the blocks:

grafik

Any idea how to get rid of that?
I'm using kitty/putty in windows.

Bandwidth optimization: don't emit duplicate color codes

emit_color is unconditionally called within emit_image, and itself unconditionally emits the color codes. If the previous character cell had the same colors, this is redundant.

Proposed: emit_color maintains a copy of the last foreground and background used, possibly as simply as keeping the string that was emitted. If it's about to emit the same one, return without emitting anything.

Challenges:

  • Need to initialize the last_foreground/last_background to something that cannot happen, or add a flag to indicate that it's uninitialized
  • What happens at the line ending, especially if -c starts applying to full image mode? Probably need to do a full reset on reaching the end of the line and set the last_* variables to their initial states.
  • For real-world data, the benefits might be too trivial to justify the increase in code complexity.

(This is really stefanhaustein's idea, mentioned to me in an email. I'm adding it because it sounds like a fun little project to me, not because I need it. So unless someone else has a more specific requirement, I'd consider this "wishlist" level.)

Decoding errors with 256 color PNG file

I have this PNG file which either decodes with wrong colors and artifacts, or just crashes.

lageplan_joey
(Here's hoping github doesn't somehow recompress images making the problem go away)

It seems this is an issue with CImg, I tried getting the latest version from their git but the problem persists. Compiling with -Dcimg_use_png and linking against libpng fixes the issue, but it seems you want to avoid linking any external libraries.

Tall images are mishaped in thumbnail mode

If an image is tall and skinny, it will be stretched wide in thumbnail node.

Actual behavior:
ss-bad

Expected behavior:
ss-good

(I'm using the 1,280 × 307 pixels version ofhttps://commons.wikimedia.org/wiki/File:Sunset_Toronto_Skyline_Panorama_from_Snake_Island.jpg as a test image; the skinny one is just a rotated version of the first.)

(Edit: Replaced the image from Konsole with images from gnome-terminal, which does not exhibit the wonky artifacts.)

Odd results with true greyscale images

True greyscale images exhibit odd behavior. Sometimes tiv simply crashes. But most of the time the image is very strangely rendered. I think tiv is assuming 3 channels, but CImg is only providing 1, so things are mapped strangely and in some cases tiv just tries to read invalid memory.

This is my test image.

Actual behavior:
bad-abe

Expected behavior:
good-abe

having problems with screenshots

The following image gives an error:

desktop_extracted

[CImg] *** CImgIOException *** [instance(0,0,0,0,(nil),non-shared)] CImg<unsigned char>::load(): Failed to open file './desktop_extracted.jpg'.

Imagemagick does not have problems with it. The picture even originates from the X-window capturing tool of imagemagick.

> import -window root file.png
> tiv file.png

[CImg] *** CImgIOException *** [instance(0,0,0,0,(nil),non-shared)] CImg<unsigned char>::load(): Failed to open file 'file.png'.
File format is not recognized for 'file.png'

Support for Windows

I found your tool, and checked it I can use it with putty or the windows bash. It works on both, but it is displaying that some symbols which are not supported.

How did you find out which symbols are supported so that I can try to filter them out?

shell

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.