GithubHelp home page GithubHelp logo

rossy / img2xterm Goto Github PK

View Code? Open in Web Editor NEW
171.0 171.0 13.0 320 KB

Displays images on your 256-color terminal with Unicode block characters.

Home Page: http://img2xterm.sooaweso.me

License: Creative Commons Zero v1.0 Universal

C 79.60% Makefile 11.60% Groff 8.80%

img2xterm's Introduction

Banner

img2xterm's People

Contributors

keithw avatar rossy 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

img2xterm's Issues

Unicode characters not correctly printed with cow image

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 -- "こんにちは世界"
 _______________________
< ������� >
 -----------------------
           \
            \
             \
              \
            ▄▄▄
▄▄▄▄ ▄▄▄▄ ▄ ▄
  ▄    ▄▄▄▄▄▄▄▄
▀▄   ▄▄▄▄      ▄
  ▀ ▄  ▄▄ ▄▄   ▄
  ▄▄    ▄▄▄▄▄▄▄▄▄
    ▄▄▄▄▄    ▄ ▄▀
   ▀▀  ▀▄▄▄▄▄▄▀
        ▀▄▄▀▀

screen shot 2016-10-04 at 14 49 04

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.
           \
            \
             \
              \
  ▄▄          ▄▄
▄▄ ▄▄▄▄▄▄     ▄▄▄
▀▄▄  ▄▄  ▄▄▄ ▀▄▄ ▄
  ▀▄▄  ▄▄▄▄ ▄▄▄  ▄▄▄
   ▄▄ ▄▄▀ ▄ ▄▄▄▄  ▄▄▄
   ▀▄ ▄▄▄  ▄▄▄▄ ▄▄▄▄▀
    ▄▄▄▄▄▄  ▄▄ ▄▄▄▄▄▀
     ▀▄▄  ▄▄▄▄  ▄
      ▀▄    ▄▄▄▀
        ▀▄▄▀

screen shot 2016-10-04 at 14 48 08

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

Dithering

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.

Add unicode block character support

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

Support newer versions of imagemagick

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...

Document requirements for debian

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/

License is non-free

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.

Makefile ncurses5-config

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.

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.