Graphics in a text world.
Graphics in a text world.
Graphics in a text world.
Graphics in a text world.
Sometimes when sitting at a text only terminal, It would be nice to see some kind of picture even if it was crude. For example, you just got an email saying you have to look at this picture! Here you will get a chance to experiment with pictures from the command line. Thought not perfect, you may have to stand back a bit to get the full effect of the pictures. Also too, if you want to put pictures on the text only lcd signs, this is a good way to convert the pictures.

Note: the higher screen resolution you are using will improve the pictures.

Step 1: Get some software.

Graphics in a text world.
You will need a jpg to ascii converter, image converter, and a page grabber.

For Ubuntu based machines:
sudo apt-get install jp2a imagemagick curl wget

Step 2: Conversion to jpg format.

Graphics in a text world.
Graphics in a text world.
Someone just sent me the robot picture which is in ,png format.I need a jpg format. No problem...

$ convert robot.png robot.jpg

Now you want to display the picture.

$ jp2a -b --colors rogot.jpg

it is that simple.

Step 3: Getting pictures from the web.

Graphics in a text world.
Graphics in a text world.
Graphics in a text world.
This is a little more tricky. For now we will do it the crude way. Now someone has said you need to look at a picture at www.cnn.com.

Lets get all the picture names from the from page of www.cnn.com and save the data.

$ curl www.cnn.com | grep ".jpg" > cnn.txt

$ nano cnn.txt

You will want to pick out the important file name of the picture.you want to use

$ wget http://i2.cdn.turner.com/cnn/2011/images/10/21/t1main.1228.libya.celeb.afp.gi.jpg

Display the pic.

$ jp2a -b --colors t1main.1228.libya.celeb.afp.gi.jpg

or

$ jp2a -b --colors http://i2.cdn.turner.com/cnn/2011/images/10/21/t1main.1228.libya.celeb.afp.gi.jpg

I probably did not pick out the best picture to display, but that is how it goes sometimes. Better than nothing.
--------------------------------------------------------------------------

$ curl www.cnn.com | grep ".jpg" > cnn.txt
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 107k 100 107k 0 0 192k 0 --:--:-- --:--:-- --:--:-- 270k
$ nano cnn.txt
$ vim cnn.txt
$ wget http://i2.cdn.turner.com/cnn/2011/images/10/21/t1main.1228.libya.celeb.afp.gi.jpg
--2011-10-21 12:02:29-- http://i2.cdn.turner.com/cnn/2011/images/10/21/t1main.1228.libya.celeb.afp.gi.jpg
Resolving i2.cdn.turner.com... 8.26.219.254, 205.128.65.126, 204.160.102.126
Connecting to i2.cdn.turner.com|8.26.219.254|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 17983 (18K) [image/jpeg]
Saving to: `t1main.1228.libya.celeb.afp.gi.jpg'

100%[===================================================================================>] 17,983 --.-K/s in 0.04s

2011-10-21 12:02:29 (429 KB/s) - `t1main.1228.libya.celeb.afp.gi.jpg' saved [17983/17983]

Step 4: Cartoons.

Graphics in a text world.
Graphics in a text world.
Graphics in a text world.
Sometimes solid picture cartoons come out better. Just depends...

Step 5: Screen size benefit.

Graphics in a text world.
Graphics in a text world.
Graphics in a text world.
As I said the bigger the screen, clarity should get better.

Step 6: Invert it.

Graphics in a text world.
Graphics in a text world.
Sometimes using the invert option (-i) can increase clarity. If you want to print it out, lots of ink will be saved also.

$ jp2a -b -i abe.jpg
$ _

Step 7: Web page graphic.

Graphics in a text world.
Graphics in a text world.
Create a web page graphic with:

$ jp2a --color --html --fill --background=light hs.jpg --output=hs.html

to display:

$firefox hs.html

Step 8: Video using text only.

Graphics in a text world.
You can also do videos as text also. Use to do this on an old text (only) unix terminal. It blew peoples minds.

$ sudo apt-get install mplayer caca-utils
$ mplayer -vo caca -quiet tbhs--0025--hak5--small.h264.mp4 (Sound not included to save uploading bandwidth.)

or without speakers and or a sound card

$ mplayer -vo caca -ao null -quiet tbhs--0025--hak5--small.h264.mp4 (Sound not included to save uploading bandwidth.)

Update: You can get youtube videos with youtube-dl

$ sudo apt-get install youtube-dl

Grab the file: youtube [youtube url]

$ youtube-dl http://www.youtube.com/watch?v=4XGq3SZEDZI




On a real ascii terminal.


Step 9: Yaicp.

Graphics in a text world.
Graphics in a text world.
Graphics in a text world.
Yet another image conversion program.

Get the software:

$ sudo apt-get install caca-utils

Get the pic

getpic::
[code]
DAY=$(date +"%m%d%y%H%M%S")
picfn="pic$DAY.png"
# echo $picfn
wget http://radar.weather.gov/ridge/Thumbs/HGX.png -O hgx$DAY.png
[/code]

Convert

$ img2txt -W 80 -f utf8 img2txt -W 80 -H 25 -f utf8 hgx110711051503.png > hgx110711051503.txt

Display

$ cat hgx110711051503.txt



Step 10: Ascii analog clock.

Graphics in a text world.
Graphics in a text world.
Graphics in a text world.
Linux Analog clock (try at your own risk)


Compile with gcc aclock-unix-curses.c -o aclock -lcurses -lm

[code]
/*
* aclock - ascii clock for UNIX Console
* * Copyright (c) 2002 Antoni Sawicki * Version 1.8 (unix-curses); Dublin, June 2002 * * Compilation: cc aclock-unix-curses.c -o aclock -lcurses -lm * Debian compilation: gcc clock.c -o clock -lcurses -lm * */ #include #include #include #include #ifndef M_PI #define M_PI 3.14159265358979323846 #endif void draw_circle(int hand_max, int sYcen, int sXcen, int FontHW){ int x,y,r; char c; for(r=0;rtm_min/10), 2*hand_max/3, 'h', sXcen, sYcen, FontHW); draw_hand(ltime->tm_min, hand_max-2, 'm', sXcen, sYcen, FontHW); draw_hand(ltime->tm_sec, hand_max-1, '.', sXcen, sYcen, FontHW); mvaddstr(sYmax/4, sXcen-5, ".:ACLOCK:."); mvprintw(4*sYmax/5, sXcen-5, "[%02d:%02d:%02d]", ltime->tm_hour, ltime->tm_min, ltime->tm_sec); refresh(); sleep(1); } endwin(); return 0; }

[/clock]

--------------------------------

Another clock: http://webonastick.com/vtclock/

Step 11: Yet another command line clock

Graphics in a text world.
You can get tty-clock at: https://github.com/xorg62/tty-clock

Step 12: Couple of New year's scripts.

Graphics in a text world.
Countdown clock:

Must be run on a linux box with figlet installed.

$ sudo apt-get update
$ sudo apt-get install figlet

Code:

$ while [[ $(date +%Y) -ne 2012 ]];do figlet $(($(date -d 2012-01-01 +%s)-$(date +%s)));sleep 1;clear;done;figlet 'Happy New Year!'

-----------------------------------------------------------------

Fireworks:

Fireworks.sh
[code]
#!/bin/bash

rows=$(tput lines)
cols=$(tput cols)
colors=(red green blue purple cyan yellow brown)
lock_file=
lock_file_base=/tmp/$(basename $0 .sh)

multiple=0
if [[ "$1" ]]; then
nsingle=$1
shift
else
nsingle=10
fi
if [[ "$1" ]]; then
nmultiple=$1
shift
if [[ $nmultiple -gt 8 ]]; then nmultiple=8; fi
else
nmultiple=6
fi


function colorstr()

local row=$1
local col=$2
local color=$3
local v
case "$color" in
red) v=31;;
green) v=34;;
blue) v=32;;
purple) v=35;;
cyan) v=36;;
yellow) v=33;;
brown) v=33;;
white) v=37;;
*) v=;;
esac
shift 3

if [[ $multiple -ne 0 ]]; then
touch $lock_file
while [[ $(ls $lock_file_base.* 2>/dev/null

function center_colorstr()
{
local row=$1
local color=$2
shift 2
local s="$*"
local slen=${#s}
colorstr $row $(((cols / 2) - (slen / 2))) $color "$s"
}

function fireworks()
{
local row=$((rows - 1))
local col=$(((RANDOM % (cols / 2)) + (cols / 4)))
local height=$((RANDOM % rows - 2))
local slant
local h
local color1=${colors[$((RANDOM % ${#colors[*]}))]}
local color2=${colors[$((RANDOM % ${#colors[*]}))]}
local color3=${colors[$((RANDOM % ${#colors[*]}))]}
while [[ $color1 == $color2 || $color1 == $color3 || $color2 == $color3 ]]
do
color2=${colors[$((RANDOM % ${#colors[*]}))]}
color3=${colors[$((RANDOM % ${#colors[*]}))]}
done

case $((RANDOM % 4)) in
0) slant=-2;;
1) slant=-1;;
2) slant=1;;
3) slant=2;;
esac

if [[ $height -gt 5 ]]; then
h=$height

while [[ $h -gt 0 ]]
do
colorstr $row $col $color1 '.'
let row--
if [[ $((col + slant)) -ge $((cols - 3)) || $((col + slant)) -le 2 ]]; then break; fi
let col+=slant
let h--
sleep 0.1
done

if [[ $((col + slant)) -lt $((cols - 3)) && $((col + slant)) -gt 2 ]]; then

h=$((height / 5))

while [[ $h -gt 0 ]]
do
colorstr $row $col $color2 '.'
let row++
if [[ $((col + slant)) -ge $((cols - 3)) || $((col + slant)) -le 2 ]]; then break; fi
let col+=slant
let h--
sleep 0.1
done
fi

colorstr $((row)) $((col - 1)) $color3 '***'
colorstr $((row - 1)) $((col)) $color3 '*'
colorstr $((row + 1)) $((col)) $color3 '*'
fi
}

for i in $(seq 1 $nsingle)
do
clear
fireworks
sleep 1
done

clear

pids=
for i in $(seq 1 $nmultiple)
do
let multiple++
lock_file=$lock_file_base.$i
fireworks &
pids="$pids $!"
done

trap "kill -9 $pids 2>/dev/null" EXIT

wait $pids
sleep 3

clear
center_colorstr $((rows / 2 - 1)) red "Hope you enjoyed the show!"
center_colorstr $((rows / 2 + 1)) red "Happy New year!! "
center_colorstr $((rows / 2 + 3)) red "Computothought"
echo

sleep 5
clear


# vim: tabstop=4: shiftwidth=4: noexpandtab:
# kate: tab-width 4; indent-width 4; replace-tabs false;

[/code]

Create shell batch file:
$ vim fireworks.sh

Make it executable:
$ chmod +x fireworks.sh

Run it:
$ ./fireworks.sh

Step 13: Ascii art.

Graphics in a text world.
There is a lot of ascii art on the net but it is disappearing fast..

__ __ __ __ _ / //_/_ ______ ____ _ / / / /__ (_) / ,< / / / / __ \/ __ `/ / /_/ / _ \/ / / /| / /_/ / / / / /_/ / / __ / __/ / /_/ |_\__,_/_/ /_/\__, / /_/ /_/\___/_/ /____/ ______ __ ________ / ____/___ _/ /_ / ____/ /_ ____ __ __ / /_ / __ `/ __/ / / / __ \/ __ \/ / / / / __/ / /_/ / /_ / /___/ / / / /_/ / /_/ / /_/ \__,_/\__/ \____/_/ /_/\____/\__, / /____/ ___......----:'"":--....(\ .-':'"": : : : : : :.(1\.`-. .'`. `. : : : : : : : : : : .'; :-`. : . : : `. : : :. : :`.`. a; : ;-. `-.-._. : : : ::. .' `. `., = ; :-:.` .-. _-., : : : ::,.'.-' ;-. ,'''" .'.' ;`. .-' `-.: : : : :;.-'.-.' `-' :. .'.'.-' .'`-.' -._;..:---'''"~;._.-; :`--'.' : :' ;`-.; :.`.-'`. `'"` : : ;`.; :=; `.-'`. : '. : ; :-: `._-`. `'"' `. `. `--' `._; `'"' | _____ | _____ \ / /______ | | / /_ / | | ()____)+()____) ----- / | | -+-. /_.|_|/_. | | ()____)+()____) \ / /___ __|__ | | | | / | | / | | ()____)+()____) ----- | | | | |_| _|_|_ /_\`-'/_\ | | ()____)+()____) __|__ | | __|_|____ | | ___|___ | | ()____)+()____) /|\ | | | | / \ _/|\_ * * / | \ __ __ ____ __ __ __ _ \ \/ /__ ____ ______ ____ / __/ / /_/ /_ ___ / /_(_)___ ____ _____ \ / _ \/ __ `/ ___/ / __ \/ /_ / __/ __ \/ _ \ / __/ / __ `/ _ \/ ___/ / / __/ /_/ / / / /_/ / __/ / /_/ / / / __/ / /_/ / /_/ / __/ / /_/\___/\__,_/_/ \____/_/ \__/_/ /_/\___/ \__/_/\__, /\___/_/ /____/

Step 14: Starwars

Graphics in a text world.

You can also watch the Starwars video with a real telnet connection.

$ telnet towel.blinkenlights.nl

You can also save the telnet session with ttyrec (you may need to install ttyrec or compile from source at http://sourceforge.net/projects/ttyrec/ , if your distro does not have it included) for later playback.

$ ttyrec starwars

$ telnet towel.blinkenlights.nl

d (control + d)

$ ttyplay starwars.

Step 15: Simple metronome.

Graphics in a text world.
Graphics in a text world.

simple metronome program that works on ascii terminals. there is no sound just all visual. You can call the program with

$ ./metronome [speed]

Compile the code with:

$ gcc metronome.c -o metronome


Graphics in a text world.
metronome.c1 KB

Step 16: Holiday trees.

Graphics in a text world.
Graphics in a text world.

Code is at:

http://computoman.blogspot.com/2014/12/simple-holiday-tree.html

Step 17: Arduino ascii output.

Graphics in a text world.

The c compiler just loves the "\".

 
 

Tag cloud

make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel