ConsoleVideo

Posted: 15 Jul 2020. Last modified on 04-Jun-22.

This article will take about 2 minutes to read.


See the code for this project here


ConsoleVideo is a set of image and video modification tools. It can be used to display the contents of an image, normalize the colors in the image, or apply a palette to the image.

Notably, it will output to the terminal. I decided to implement the ANSI console spec to get colors working, using 2 colors per character by setting a foreground and a background on a ‘▄’ character. There were a couple of different styles that I tried out, such as ‘░’, ‘▒’, ‘▓’, but they did not give the same pixelated look I was going for.

I’m interested in braille art - it would be a cool area to explore for future iterations of the tool.

This could potentially be useful in a headless environment, but it was mostly a way to try out color correction techniques in a fun new way.

This is a full list of its arguments:


usage: CMD
 -H,--help             prints this help text and exits.
 -P,--reducePalette    reduces the color space of the palette file by the
                       given amount, 256/x
 -c,--compat           requests to use the reduced ansi color set
 -f,--file             the file to be read
 -h,--height           the maximum height of the generated video
 -n,--normalize        normalizes the color value so it will use the
                       maximum amount of the color palette.
 -p,--palette          indicates an optional palette file which will be
                       used to color the output.
 -r,--reduced          reduces the color space by the given amount, 256/x
 -v,--version          version of this library
 -w,--width            the maximum width of the generated video

Following are some examples of the output of the tool:


./r.sh "-f assets/Lenna.png -h 50"

Default styling, downsampled to a max height of 50px.

All examples will be downsampled the same way, to be compact.


./r.sh "-f assets/Lenna.png -h 50 -n"

Normalizing RGB values (color correction)


./r.sh "-f assets/Lenna.png -h 50 -p assets/palettes/oil-6-1x.png"

Application of an oil slick palette


./r.sh "-f assets/Lenna.png -h 50 -p assets/palettes/softdecay-gb-1x.png"

Application of a soft “gameboy” palette


./r.sh "-f assets/Lenna.png -h 50 -r 40"

Colorspace reduction, using 1/40 of the available colorspace


./r.sh "-f assets/Lenna.png -h 50 -r 60 -n"

Colorspace reduction paired with normalization