Turn images into text better than caca/aalib

Overview

hiptext Build Status

hiptext is command line tool for rendering images and videos inside terminals.

Last Supper in Macterm

Happy Cat in Macterm

Obama in Macterm

Dependencies

You need clang or gcc >=4.7. You also need to install:

sudo apt-get install build-essential libpng12-dev libjpeg-dev \
    libfreetype6-dev libavformat-dev libavcodec-dev \
    libswscale-dev libgflags-dev libgoogle-glog-dev ragel

Installation

wget https://github.com/jart/hiptext/releases/download/0.2/hiptext-0.2.tar.gz
tar xvzf hiptext-0.2.tar.gz
cd hiptext-0.2

./configure
make -j4
sudo make install

Usage

Images

Most image types, e.g. JPEG, PNG, GIF, etc. are supported.

hiptext balls.png

Videos

You can play videos in your terminal using hiptext. Yes, really.

youtube-dl -o gangnam-style.mp4 https://www.youtube.com/watch?v=9bZkp7q19f0
hiptext gangnam-style.mp4

Miscellaneous

hiptext --spectrum
hiptext --nocolor balls.png
hiptext --nocolor --chars=" .oO0" balls.png

Rendering Modes

xterm256

By default, hiptext assumes you're using an xterm256 compatible terminal, e.g. gnome-terminal, without bothering to check the TERMINAL environment variable.

hiptext --xterm256 balls.png

To double the number of pixels using Unicode half blocks, consider using the following option, which may become the default in the future:

hiptext --xterm256unicode balls.png

MacTerm

The most beautiful terminal for hiptext is the one built into Mac OS X called Terminal.app. This terminal uses xterm256 but it's implemented using a custom color palette that was chosen by designers rather than engineers.

But the interesting thing about this palette is that it uses slightly different colors for foreground and background. By using Unicode half blocks, this allows us to simulate something closer to 512 colors!

hiptext --macterm balls.png

However to use this, you must be using the black color scheme. After all, why would you use anything else?

Unicode

If you want to render an image without the ANSI color escape codes, you can use the --nocolor flag. This will render the image using shaded unicode block characters.

hiptext --nocolor balls.png

ASCII

The no-color mode supports a very simple character quantiser that can convert images to ASCII. Please understand that if this is what you want, there are much better tools for the job, like cacalib.

hiptext --nocolor --chars=" .oO0" balls.png

SIXEL

If you use a SIXEL terminal, e.g. mlterm >=v3.1.3, then the following flags can provide much more minute rendering:

hiptext --sixel256 balls.png           # For 256-color SIXEL terminal such as mlterm (>=v3.1.3)
hiptext --sixel16 balls.png            # For 16-color SIXEL terminal such as xterm(patch level >= #294) with "-ti vt340 option"
hiptext --sixel2 balls.png             # For monochrome SIXEL terminals

Configuration

Background

By default, hiptext assumes that your terminal background is black. If this is not the case, you can specify your background color using a CSS or X11 color string.

hiptext --bg=white balls.png
Issues
  • Dependencies on a Mac...

    Dependencies on a Mac...

    Disclaimer: It's been ages since I've compiled a darn thing... Feel free to tell me to RTFM... just point me in the right direction first :)

    I'm having a hell of a time getting hiptext compiled... Looking to do this from OS X and I've been using MacPorts, since it seemed like the easiest way to grab most of the dependencies you'd listed (grabbed ffmpeg, wget for your install-g*.sh scripts, and ragel). I believe I'm using gcc4.8 — at least the MacPorts version.

    At this point when I make I'm getting an output of:

    c++ -g -O3 -std=c++11 -Wall -Wextra -Werror -fno-exceptions -fno-rtti -MD -march=native -c -o hiptext.o hiptext.cc /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3204:no such instruction: vmovsd 504(%rsp), %xmm0' c++ -g -O3 -std=c++11 -Wall -Wextra -Werror -fno-exceptions -fno-rtti -MD -march=native -c -o hiptext.o hiptext.cc /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3204:no such instruction:vmovsd 504(%rsp), %xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3205:no such instruction: vucomisd 8(%rdx), %xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3209:no such instruction:vmovsd 512(%rsp), %xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3210:no such instruction: vucomisd 16(%rdx), %xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3214:no such instruction:vmovsd 520(%rsp), %xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3215:no such instruction: vucomisd 24(%rdx), %xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3223:no such instruction:vmovsd (%rax), %xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3233:no such instruction: vaddsd 8(%rax), %xmm0,%xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3234:no such instruction:vaddsd 16(%rax), %xmm0,%xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3235:no such instruction: vdivsd LC49(%rip), %xmm0,%xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3236:no such instruction:vmulsd 24(%rax), %xmm0,%xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3240:no such instruction: vmulsd LC50(%rip), %xmm0,%xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3241:no such instruction:vcvttsd2si %xmm0, %eax' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3355:no such instruction: vmovsd 496(%rsp), %xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3379:no such instruction:vucomisd (%rdx), %xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3387:no such instruction: vmovsd (%rax), %xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3390:no such instruction:vaddsd 8(%rax), %xmm0,%xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3391:no such instruction: vaddsd 16(%rax), %xmm0,%xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3392:no such instruction:vdivsd LC49(%rip), %xmm0,%xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3393:no such instruction: vmulsd 24(%rax), %xmm0,%xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3397:no such instruction:vmulsd LC50(%rip), %xmm0,%xmm0' /var/folders/m_/6p8v1kgj1_n_56hr05k8f_z40000gn/T//ccDk5vz7.s:3398:no such instruction: `vcvttsd2si %xmm0, %ecx'

    At this point I haven't the foggiest as to what I should try next. :/ Any suggestions, are hugely appreciated.

    opened by dsteele7 16
  • Compile Error

    Compile Error

    $ make g++ -g -O3 -std=c++11 -Wall -Wextra -Werror -fno-exceptions -fno-rtti -MD -march=native -c -o hiptext.o hiptext.cc g++ -g -O3 -std=c++11 -Wall -Wextra -Werror -fno-exceptions -fno-rtti -MD -march=native -c -o artiste.o artiste.cc g++ -g -O3 -std=c++11 -Wall -Wextra -Werror -fno-exceptions -fno-rtti -MD -march=native -c -o charquantizer.o charquantizer.cc g++ -g -O3 -std=c++11 -Wall -Wextra -Werror -fno-exceptions -fno-rtti -MD -I/usr/include/freetype2 -march=native -c -o font.o font.cc g++ -g -O3 -std=c++11 -Wall -Wextra -Werror -fno-exceptions -fno-rtti -MD -march=native -c -o graphic.o graphic.cc g++ -g -O3 -std=c++11 -Wall -Wextra -Werror -fno-exceptions -fno-rtti -MD -march=native -c -o jpeg.o jpeg.cc g++ -g -O3 -std=c++11 -Wall -Wextra -Werror -fno-exceptions -fno-rtti -MD -march=native -c -o macterm.o macterm.cc g++ -g -O3 -std=c++11 -Wall -Wextra -Werror -fno-exceptions -fno-rtti -MD -march=native -c -o movie.o movie.cc movie.cc: In destructor ‘Movie::~Movie()’: movie.cc:42:48: error: ‘avformat_close_input’ was not declared in this scope if (format_) avformat_close_input(&format_); ^ make: *** [movie.o] Error 1

    opened by whit2333 13
  • Issue #16 Sixel support

    Issue #16 Sixel support

    This PR is a quick implementation of SIXEL graphics(Issue #16).

    It introduces the following new options.

    -sixel2 : emit monochrome sixel
    -sixel16 : emit 16-color sixel
    -sixel256 : emit 256-color sixel
    

    Note that we can get more beautiful picture using palette re-definition sequence If this software can do dynamic-palette quantization method(such as median-cut), but I didn't know how to do it.

    DEMO

    • mlterm (it works with X11 / frame buffer / win32 version, http://mlterm.sourceforge.net) mlterm
    • xterm with "-ti vt340" option (color palette is limited up to 16) xterm-ti340
    • RLogin (Japanese high spec terminal emulator. it also implements ReGIS. see http://nanno.dip.jp/softlib/man/rlogin/#REGWIND) rlogin
    • tanasinn (A firefox extension, see http://zuse.jp/tanasinn/) tanasinn

    I tested this patch on above 4 terminals.

    opened by saitoha 5
  • Sixel support?

    Sixel support?

    I was wondering whether xterm's support for sixel graphics might offer higher-quality output. (Dunno if any other terminal emulators support sixels. I'd be surprised.)

    opened by rrthomas 3
  • Errors on each run after make install

    Errors on each run after make install

    If i run hiptext from the directory I compiled it from it works fine. After running make install I get an error on the same images that it previously displayed without errors.

    F0325 13:59:22.764736   601 font.cc:32] Check failed: 0 == FT_New_Face( g_library, FLAGS_font.c_str(), FLAGS_font_index, &g_face) (0 vs. 1) 
    *** Check failure stack trace: ***
        @     0x7f09022d096a  (unknown)
        @     0x7f09022d08a5  (unknown)
        @     0x7f09022d0299  (unknown)
        @     0x7f09022d3297  (unknown)
        @           0x40d7e4  InitFont()
        @           0x403fe2  main
        @     0x7f08ff68aead  (unknown)
        @           0x40adbd  (unknown)
    [1]    601 abort      hiptext 2012-08-23_19-10-52_570.jpg
    
    opened by ghost 3
  • Where is pixel_parser.cc?

    Where is pixel_parser.cc?

    When I use make -j4 to compile the program , a source code called 'pixel_parser.cc' has missed. I wonder where could I find this file, or wasI just did something wrong ?

    opened by fCorleone 2
  • Missing libgflags.pc on ubuntu 1604

    Missing libgflags.pc on ubuntu 1604

    To build this on ubuntu 1604 the configure will fail to find libgflags.pc which was missing from ubuntu. I added it manually to /usr/lib/x86_64-linux-gnu/pkgconfig/libgflags.pc with content like:

    prefix=/usr
    exec_prefix=${prefix}
    libdir=${prefix}/lib/x86_64-linux-gnu
    includedir=${prefix}/include
    
    Name: gflags
    Version: 2.0
    Description: A commandline flags library that allows for distributed flags
    URL: http://code.google.com/p/gflags
    Requires:
    Libs: -L${libdir} -lgflags
    Libs.private: -pthread -lpthread
    Cflags: -I${includedir}`
    
    opened by laoshaw 2
  • could not find  ft2build.h

    could not find ft2build.h

    On ubuntu 16.04 x86 I got : src/font.cc:6:22: fatal error: ft2build.h: No such file or directory

    I manually added -I /usr/include/freetype2 to get it compiled, something configure script did not get the include path right.

    opened by laoshaw 2
  • Alias the `sig_t` type to `sighandler_t` on Macs

    Alias the `sig_t` type to `sighandler_t` on Macs

    … apparently the Apple/BSD signal.h interface is exactly the same as what’s on Linux, except for this. The codebase as it stands, on master at HEAD, errors out during make like so:

    asio-otus:hiptext[master]$ make
    c++ -g -O3 -std=c++11 -Wall -Wextra -fno-exceptions -fno-rtti -MD  -march=native -c -o hiptext.o hiptext.cc
    c++ -g -O3 -std=c++11 -Wall -Wextra -fno-exceptions -fno-rtti -MD  -march=native -c -o artiste.o artiste.cc
    artiste.cc:165:3: error: unknown type name 'sighandler_t'
      sighandler_t old_handler = signal(SIGINT, OnCtrlC);
      ^
    1 error generated.
    make: *** [artiste.o] Error 1
    

    … but if I include the one alias per the PR, hiptext builds OK (with both Apple Clang 6.2 something and also LLVM Clang, somewhat recent HEAD from the 3.7 branch) and but then everything runs completely as advertised in every way thereafter:

    screen shot 2015-08-08 at 12 19 33 pm

    Yes!

    opened by fish2000 2
  • Fix signal handler

    Fix signal handler

    opened by elfring 2
  • Catch exceptions in main()?

    Catch exceptions in main()?

    opened by elfring 2
  • korean chinese

    korean chinese

    Thank you for the resources I would like to ask how are they based on our de based on the English or are they converting the letters into English characters or ask characters I have tried to run it and I didn't understand which comments that I should look on it seems that you have committed something four months ago is it related with four years ago as well thank you so much

    opened by Estheryu991 0
  • Update this please

    Update this please

    Hi there, there are some changes in ffmpeg and so the interface call signatures have been changed. Update this please, so we can all enjoy the ascii goodness

    opened by muziker 10
  • fails if not called from terminal

    fails if not called from terminal

    Even if you specify -width and -height, it tries calling ioctl TIOCGWINSZ, fails and crashes. ┐(´д`)┌

    Ran into this trying to use hiptext as an image preview in ranger.

    opened by Rouji 0
  • Why pixel_parse.cc is only in the archive ?

    Why pixel_parse.cc is only in the archive ?

    Hi, pixel_parse.cc is not in the repo. And it's very weird :

    $ wc pixel_parse.cc -l 17970

    $ grep goto pixel_parse.cc | wc -l 7592

    7592 GOTO !!! It's just insane ^^.

    opened by trent30 1
  • build error in ffmpeg 4.0

    build error in ffmpeg 4.0

    error occur in ffmpeg 4.0

    src/movie.cc:70:38: error: use of undeclared identifier 'PIX_FMT_RGB24'; did you mean 'AV_PIX_FMT_RGB24'
    src/movie.cc:94:5: warning: 'av_free_packet' is deprecated
    src/movie.cc:65:22: error: use of undeclared identifier 'avcodec_alloc_frame'
    

    send pull requests https://github.com/jart/hiptext/pull/52 but Travis CI refused because of using the earlier ffmpeg

    opened by WindProphet 1
Releases(0.2)
Owner
Justine Tunney
Justine Tunney
Phan Sang 8 Jul 30, 2022
An optimized "RTOS" (more than HAL but less than RTOS) for ROV controling and getting sensor data

Nitori-ROV-OS 一个专门为水下机器人(ROV、AUV)进行优化的实时操作系统,暂命名为 Nitori,中文名 荷取 可以通过修改硬件兼容层(Port)进行移植 预计最初版本支持stm32f407和stm32h750,并在实验室目前的水下机器人中进行部署 系统分为四层,六个主要组件: 硬件

Doublues_G 2 Jan 10, 2022
Raw HID keyboard forwarder to turn the Pi 400 into a USB keyboard

Raspberry Pi 400 as a USB HID Keyboard Hook your Pi 400 up to your PC somehow, using a USB Type-C cable into the power port. Anker make good ones- I u

Philip Howard 157 Aug 7, 2022
Turn 2 esp32 boards into pixhawk telemetry for use with Ardupilot/Ardurover Mission Planner.

RoverLink Turn 2 esp32 boards into pixhawk telemetry for use with Ardupilot/Ardurover Mission Planner I used to use these cheap Chinese 900mhz Pixhawk

Jeffrey Berezin 2 Jan 18, 2022
Turn your ESP32 into a easy to use micro web-server allowing to interact with any GPIO by simple http(s) calls.

WebhooksTriggeredESP32WiFi Turn your ESP32 into an easy to use and manage wireless micro web-server allowing it to process reliably and asynchronouly

JayDeLux 4 Jun 1, 2022
To turn on and off the pump, most people use a manual switch.

To turn on and off the pump, most people use a manual switch. As a result, people forget to switch off the pump from time to time, resulting in water overflow. They may forget to switch on the motor at times, resulting in a water problem later on. It also wastes a lot of electricity. To solve this problem, we need a smart device to control the pump.

Md. Asad Chowdhury Dipu 1 Oct 14, 2021
Typewriter Effect with Rich Text + *Correct* Text Wrapping

Typewriter Effect with Rich Text + Correct Text Wrapping I've spent way too long getting this right. This is meant as a base class for a UMG dialogue

Sam Bloomberg 26 Jul 17, 2022
Text - A spicy text library for C++ that has the explicit goal of enabling the entire ecosystem to share in proper forward progress towards a bright Unicode future.

ztd.text Because if text works well in two of the most popular systems programming languages, the entire world over can start to benefit properly. Thi

Shepherd's Oasis 204 Jul 25, 2022
A better hexdump

huxdemp (aka hxd) huxdemp is an advanced version of the venerable hexdump that uses colors, bolding, and other terminal formatting to distinguish betw

LPTSTR 58 Jun 11, 2022
The Pizza Compass will determine your location and direct you to the nearest pizza place. It’s like a regular compass, but better!

Pizza_Compass A Particle project named Pizza_Compass Welcome to your project! Every new Particle project is composed of 3 important elements that you'

Joe Grand 66 Jul 25, 2022
Thread Stack Spoofing - PoC for an advanced In-Memory evasion technique allowing to better hide injected shellcode's memory allocation from scanners and analysts.

Thread Stack Spoofing PoC A PoC implementation for an advanced in-memory evasion technique that spoofs Thread Call Stack. This technique allows to byp

Mariusz B. 673 Aug 10, 2022
T-HYDRA is a modified version of original thc-hydra for better use inside Termux .

T-HYDRA is a modified version of original thc-hydra for better use inside Termux . Earlier , hydra pakage had been with Termux repositories. Then afte

Devil Master 34 Jul 24, 2022
Stock exchange simulator made in Swing using Java with logic backend in C++ giving it faster load time and better data control

StockSimulator Stock exchange simulator made in Swing using Java with logic backend in C++ giving it faster load time and better data control Features

Dušan Todorović 0 Mar 1, 2022
Visual-inertial-wheel fusion odometry, better performance in scenes with drastic changes in light

VIW-Fusion An visual-inertial-wheel fusion odometry VIW-Fusion is an optimization-based viusla-inertial-wheel fusion odometry, which is developed as a

庄庭达 189 Aug 6, 2022
The Better String Library

The Better String Library The Better String Library is an abstraction of a string data type which is superior to the C library char buffer string type

null 380 Aug 9, 2022
Refinements of the WFA alignment algorithm with better complexity

wfalm Refinements of the WFA alignment algorithm with better complexity Introduction This repository contains implementations of the WFA algorithm as

Jordan Eizenga 23 Jun 11, 2022
Quick fix to iphone usb tethering with ios14 or higher for Linux kernel lower than 5.10.4

Quick fix to Linux Iphone USB tethering with IOS 14 or higher (Tested with ubuntu 18.04, kernel 5.4.0-65, if you fail in the build, please download yo

null 23 Jul 8, 2022
A Minimal Web Browser with Built-in Adblocker in Less Than 100 Lines of Code

A Minimal QtWebEngine Web Browser with Adblocker How Does It Work This is a minimal network filter implementation using QWebEngineUrlRequestIntercepto

Penk Chen 19 Jul 23, 2022
Small and dirty header-only library that supports user input with some more advanced features than in the standard lib.

dirty-term Small and dirty header-only library that supports user input with some more advanced features than in the standard lib. This small, lightwe

null 3 Apr 24, 2022