Show HN: A Ruby gem to convert images into custom ASCII art

78
Show HN: A Ruby gem to convert images into custom ASCII art

Convert photos to custom ASCII artwork with code or from the shriek-line. Print photos to the console in a enjoyable draw, and rob profit of io/console terminal width to have the artwork in accordance to window dimension!

Must haves

Requires ImageMagick which is able to be downloaded right here

Set up

$ gem set up image2ascii

Exercise from shriek-line

  Usage: ascii2image [image path or URL] [options]
    -w, --width N                    Width (in characters)
    -t, --terminal-p.c N         Width as p.c of terminal dimension
    -c, --color COLOR                Coloration in hex, rgb, or by title [examples: 'red', '255, 255, 255', '#FFFFFF']
    -x, --custom CHARS               Custom-made characters in record of descending relative brightness [example: '@#-.']
    -i, --invert                     Invert ASCII personality record
    -b, --block                      Print ASCII in block accomplish
    -g, --greyscale                  Print ASCII in greyscale
    -h, --support                       Prints this support

Exercise with code

– With defaults –

– Alternate width –

    ascii = Image2ASCII.unusual("/course/to/img.jpg")
    
    ascii.generate(width: 30)
    ascii.generate(width: ascii.winsize)        #default
    ascii.generate(width: ascii.winsize / 2)    #half of window dimension

– Alternate color –

    ascii = Image2ASCII.unusual("/course/to/img.jpg")
    
    ascii.generate(color: "beefy")          #default
    ascii.generate(color: "greyscale")
    ascii.generate(color: "#FFFFFF")
    ascii.generate(color: [255, 255, 255])
    ascii.generate(color: "white")

– Print as blocks –

this can print to the terminal as blocks. Works with greyscale or beefy color.

    ascii.generate(block: fraudulent)  #default
    ascii.generate(block: staunch)

– Veil from terminal –

The “generate” shriek returns a string, to capture this string with out outputting to the terminal we can stop it from printing

    ascii_string = ascii.generate(hidden: staunch)
    puts ascii_string

– Alternate personality design –

The personality design may maybe well presumably also be modified. It shall be main that they’re ordered ascend

Join the pack! Join 8000+ others registered users, and secure chat, have teams, post updates and have mates across the world!
www.knowasiak.com/register

Ava Chan
WRITTEN BY

Ava Chan

I'm a researcher at Utokyo :) and a big fan of Ava Max