rossy / img2xterm Goto Github PK
View Code? Open in Web Editor NEWDisplays images on your 256-color terminal with Unicode block characters.
Home Page: http://img2xterm.sooaweso.me
License: Creative Commons Zero v1.0 Universal
Displays images on your 256-color terminal with Unicode block characters.
Home Page: http://img2xterm.sooaweso.me
License: Creative Commons Zero v1.0 Universal
Image not found. Where is that cow?
If I use cowsay with an image that has been converted to a cowfile and a string containing 4-byte characters, they are output incorrectly:
➜ cowsay -f cows/Eevee.cow -- "こんにちは世界"
_______________________
< ������� >
-----------------------
\
\
\
\
▄▄▄
▄▄▄▄ ▄▄▄▄ ▄ ▄
▄ ▄▄▄▄▄▄▄▄
▀▄ ▄▄▄▄ ▄
▀ ▄ ▄▄ ▄▄ ▄
▄▄ ▄▄▄▄▄▄▄▄▄
▄▄▄▄▄ ▄ ▄▀
▀▀ ▀▄▄▄▄▄▄▀
▀▄▄▀▀
If I remove binmode STDOUT, ":utf8";
from the cowfile, the message is output correctly, but instead we get a warning from perl:
➜ cowsay -f cows/Pikachu.cow -- "こんにちは世界"
_______________________
< こんにちは世界 >
-----------------------
Wide character in print at /usr/local/bin/cowsay line 71.
\
\
\
\
▄▄ ▄▄
▄▄ ▄▄▄▄▄▄ ▄▄▄
▀▄▄ ▄▄ ▄▄▄ ▀▄▄ ▄
▀▄▄ ▄▄▄▄ ▄▄▄ ▄▄▄
▄▄ ▄▄▀ ▄ ▄▄▄▄ ▄▄▄
▀▄ ▄▄▄ ▄▄▄▄ ▄▄▄▄▀
▄▄▄▄▄▄ ▄▄ ▄▄▄▄▄▀
▀▄▄ ▄▄▄▄ ▄
▀▄ ▄▄▄▀
▀▄▄▀
This is using, for example, this file:
binmode STDOUT, ":utf8";
$the_cow =<<EOC;
$thoughts
$thoughts
$thoughts
$thoughts
\e[49m \e[48;5;236m \e[38;5;179m\N{U+2584}\N{U+2584}\e[49m\e[38;5;236m\N{U+2584}
\N{U+2584}\e[48;5;236m\e[38;5;230m\N{U+2584}\e[49m\e[38;5;236m\N{U+2584}\N{U+2584}\e[48;5;236m \e[38;5;185m\N{U+2584}\N{U+2584}\e[49m\e[38;5;236m\N{U+2584}\N{U+2584} \N{U+2584}\e[48;5;236m \e[48;5;179m\e[38;5;137m\N{U+2584}\e[48;5;240m \e[48;5;179m \e[48;5;236m \e[49m
\e[48;5;236m \e[48;5;230m \e[38;5;185m\N{U+2584}\e[48;5;137m \e[48;5;239m \e[48;5;179m \e[48;5;240m \e[48;5;185m\e[38;5;240m\N{U+2584}\e[48;5;137m\e[38;5;179m\N{U+2584}\e[48;5;236m\e[38;5;240m\N{U+2584}\e[38;5;185m\N{U+2584}\e[48;5;185m\e[38;5;179m\N{U+2584}\e[48;5;239m\e[38;5;185m\N{U+2584}\e[38;5;179m\N{U+2584}\e[48;5;240m\e[38;5;239m\N{U+2584}\e[48;5;236m \e[49m
\e[38;5;236m\N{U+2580}\e[48;5;185m\N{U+2584}\e[48;5;137m \e[48;5;239m\e[38;5;240m\N{U+2584}\e[48;5;179m\e[38;5;239m\N{U+2584}\e[48;5;240m\e[38;5;179m\N{U+2584}\e[38;5;137m\N{U+2584}\e[48;5;179m \e[48;5;240m\e[38;5;231m\N{U+2584}\e[48;5;236m \e[49m
\e[38;5;236m\N{U+2580}\e[48;5;236m \e[48;5;240m\e[38;5;137m\N{U+2584}\e[48;5;137m \e[48;5;240m \e[48;5;239m\e[38;5;185m\N{U+2584}\e[48;5;179m\e[38;5;240m\N{U+2584} \e[48;5;240m\e[38;5;236m\N{U+2584}\e[48;5;137m\e[38;5;231m\N{U+2584}\e[48;5;179m \e[48;5;236m\e[38;5;179m\N{U+2584} \e[49m
\e[38;5;236m\N{U+2584}\e[48;5;236m\e[38;5;137m\N{U+2584}\e[48;5;137m \e[48;5;240m \e[48;5;185m \e[48;5;240m\e[38;5;230m\N{U+2584}\e[48;5;137m\e[38;5;240m\N{U+2584}\e[48;5;236m\e[38;5;137m\N{U+2584}\e[48;5;240m\N{U+2584}\e[48;5;179m\N{U+2584}\e[38;5;240m\N{U+2584}\e[48;5;173m\e[38;5;95m\N{U+2584}\e[48;5;236m\e[38;5;230m\N{U+2584}\e[49m\e[38;5;236m\N{U+2584}
\e[48;5;236m \e[48;5;137m \e[38;5;240m\N{U+2584}\e[48;5;240m\e[38;5;236m\N{U+2584}\e[48;5;239m\N{U+2584}\e[48;5;185m\e[38;5;240m\N{U+2584}\e[48;5;230m\e[38;5;185m\N{U+2584} \e[48;5;185m \e[48;5;230m \N{U+2584} \e[38;5;236m\N{U+2584}\e[49m\N{U+2580}
\N{U+2580}\N{U+2580} \N{U+2580}\e[48;5;137m\N{U+2584}\e[48;5;95m\e[38;5;137m\N{U+2584}\e[48;5;230m\e[38;5;239m\N{U+2584}\e[48;5;185m\N{U+2584}\e[38;5;137m\N{U+2584}\e[48;5;239m\e[38;5;236m\N{U+2584}\e[49m\N{U+2580}
\N{U+2580}\e[48;5;137m\N{U+2584}\e[48;5;179m\N{U+2584}\e[49m\N{U+2580}\N{U+2580}\e[39m
EOC
From the image in the readme.md it seems that there is some dithering process involved in the conversion. Could you add an option to disable dithering?
Also, would this work on OS X?
I am considering using img2xterm instead of img2txt in my project ASCIICover.
Some terminals support true color mode, see https://gist.github.com/XVilka/8346728
It would be cool if img2xterm optionally supported that :)
How about a version that can do 2x2 pixel blocks per character? Using the unicode ▘ ▝ ▖ ▗ ▟ ▙ ▜ ▛ ▚ ▞ ▉
Of course you do lose the ability to set color of each pixel independently, being limited to one FG and one BG color per 4-pixel block, but you get so much more detail, see:
https://abload.de/img/higgscapmvy6w.png
Compilation fails with imagemagick 7.
gcc -O2 -Wall -D_GNU_SOURCE -D_DEFAULT_SOURCE -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/ImageMagick-7 -D_FORTIFY_SOURCE=2 -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/ImageMagick-7 -o img2xterm img2xterm.c -s -lMagickWand-7.Q16HDRI -lMagickCore-7.Q16HDRI -lm -lncursesw -lMagickWand-7.Q16HDRI -lMagickCore-7.Q16HDRI
img2xterm.c:12:0: warning: "_GNU_SOURCE" redefined
#define _GNU_SOURCE
<command-line>:0:0: note: this is the location of the previous definition
img2xterm.c:18:10: fatal error: wand/MagickWand.h: No such file or directory
#include <wand/MagickWand.h>
^~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:46: img2xterm] Error 1
==> ERROR: A failure occurred in build().
Aborting...
Add a feature to not use any ansi coloring, so that the result can be opened into a regular text editor without having to copy-paste
apt-get install libmagickwand-dev imagemagick
ln -sf /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/MagickWand-config /usr/local/bin/
This software has been submitted for possible inclusion into Fedora, but the license as it stands currently is non-free, because of the following wording:
⑨. This license document permits you to DO WHAT THE FUCK YOU WANT TO as long as you APPRECIATE CIRNO AS THE STRONGEST IN GENSOKYO.
The reference to "CIRNO" and "GENSOKYO" appears to be some sort of internet meme, however, in a legal text, this clause has the effect of putting an unenforceable restriction upon the permission to "DO WHAT THE FUCK YOU WANT TO". Since this is the core permission text in the license, this makes the "Strongest Public License" non-free and non-open source.
You could resolve this by using the "WTFPL" instead, which is clearly what this license is based on, minus the unenforceable restriction. Alternately, simply dropping the text " as long as you APPRECIATE CIRNO AS THE STRONGEST IN GENSOKYO." would be sufficient. Last, but not least, if you are insistent upon keeping this "joke" clause, making it clearly optional would resolve the issue, e.g.
1. This license document permits you to DO WHAT THE FUCK YOU WANT TO.
2. At your option, you may APPRECIATE CIRNO AS THE STRONGEST IN GENSOKYO, but are not required to do so.
Thanks in advance for your help in resolving this license issue so that we can include img2xterm in Fedora.
On my system, there is no ncurses5-config, only ncursesw5-config. Altering lines 17, 19 and 20 in the makefile to match this difference fixes the linker errors I get if I try to compile otherwise.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.