GithubHelp home page GithubHelp logo

asciiart's Introduction

Developed At:

+----------------------------------------------------------------------------------------------------+
|oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oo:       ~oooo~   +oooo+:~     :o~      ~ :+   ~oooo+   ~o+        o+       ~+ooo~ ~oooo:   :oooooo|
|oo:  +oooooooo:  :  +ooo  ~+oo+:+oooo:  +ooo+    :oo+    ~o+  +oooooo+  +oo++~  +o~ :ooo+  :  :ooooo|
|oo:  ~ ~~ :oo+  +o:  ooo+    ~~+ooooo:  +ooo+  +~ +o  +~ ~o+   ~ ~ ~o+  +ooooo  ~o~ ~oo+  :o+  +oooo|
|oo:  +++++oo+   :::  ~ooooo+++~  +ooo+  oooo+  +o    +o  ~o+  ++++++o+  +oooo+  :o  :oo   :::   oooo|
|oo:  ::::::+  ~::~~:  ~o  ~:::~  oooo:  +ooo+  +o+  :oo  ~o+  ~:::::o+  ~::~   +oo  ~o   :~:~:   ooo|
|oo+::::::::+::oooooo+::oo+:::~:+ooooo+::ooooo::ooo++ooo+:+oo::::::::oo::::::++oooo+:+o::+oooooo::+oo|
|oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
+----------------------------------------------------------------------------------------------------+

Installation

Add this line to your application's Gemfile:

gem 'asciiart'

And then execute:

$ bundle

Or install it yourself as:

$ gem install asciiart

Usage

In Code

require 'asciiart'
a = AsciiArt.new("/Users/sschor/Desktop/uncle_larry.jpg")
  => #<AsciiArt:0x00000100878678 @file=#<File:/Users/sschor/Desktop/uncle_larry.jpg>>
puts a.to_ascii_art
  => ...untold glory follows

or

require 'asciiart'
a = AsciiArt.new("https://f.cloud.github.com/assets/54012/36827/2081922c-5377-11e2-9e39-3fafca0cdb79.png")
  => #<AsciiArt:0x007fa889cbacf8 @data="...">
puts a.to_ascii_art
+----------------------------------------------------------------------------------------------------+
|oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|ooooooooooooooooooooooooooooooooooooooo++oo+++++++o+o+oooooooooooooooooooooooooooooooooooooooooooooo|
|ooooooooooooooooooooooooooooooooo++++++++::::::::::+:+++++++oooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooo+++::~~~......... . ........~~~::+++oooooooooooooooooooooooooooooooooooo|
|ooooooooooooooooooooooooo++++:~~.                          .~~:++++ooooooooooooooooooooooooooooooooo|
|ooooooooooooooooooooooo++:~~.       ....~~~~~~~~~~~....        .~~:+++oooooooooooooooooooooooooooooo|
|oooooooooooooooooooo+++:~         .~~:::+++++o+++++++::~~..       .~:++ooooooooooooooooooooooooooooo|
|oooooooooooooooooo++::~.      .~~:::+++o+oooooooooo+++++:::~~..     .~::++oooooooooooooooooooooooooo|
|ooooooooooooooooo++:~.      .~+++oooooooooooooooooooooooooo++:~.      .~:++ooooooooooooooooooooooooo|
|ooooooooooooooo++:~..     .~~:+++oooooooooooooooooooooooooo+++:~~.     ..~:+oooooooooooooooooooooooo|
|ooooooooooooooo+:~.     .~:+++::+++++ooooooo+ooooooooooo++++::++::~.     ..:++oooooooooooooooooooooo|
|ooooooooooooo+++~.    .~::+++:~~~~~~:::::::::~~~::::::::~~.~.~::++:~~.     ~:+oooooooooooooooooooooo|
|ooooooooooo+++:~.    ~::++++:.        ...          ...       .~~::++::~.   .~:++oooooooooooooooooooo|
|oooooooooooo+:~..  ..:++o+++:.                                .~:+++++:.   ..~:++ooooooooooooooooooo|
|ooooooooooo+::..  ..:++ooo+:~.                                .~:+ooo++~~. ...~:+ooooooooooooooooooo|
|ooooooooooo+:~. ...~:+ooo++:~.                                ..~:++oo+:~..  ..:+ooooooooooooooooooo|
|oooooooooo++~. . .~:++o++:~~.                                   ..~++o++:~..  .:+ooooooooooooooooooo|
|ooooooooooo:~.  .~::+oo++~~                                       ~:+o+++:.   .~++oooooooooooooooooo|
|oooooooooo++:.  .~::++o+:~.                                      .~++oo++:~.  .:+o+ooooooooooooooooo|
|ooooooooooo:~. ...::+oo+:~.                                       ~:+oo++:~.  .:+++ooooooooooooooooo|
|oooooooooo++:.  .~:+++o+:~                                       .~++o++:~~   .~+ooooooooooooooooooo|
|ooooooooooo+~.  .~~:+ooo+~.                                      .~:+o+++~~.  .~+ooooooooooooooooooo|
|ooooooooooo:~..  .~:+++++~~.                                     .~+o+o+:~.   .:++oooooooooooooooooo|
|ooooooooooo+~..  ..~:++o+::..                                   .~:+oo++:~.   ~:+ooooooooooooooooooo|
|ooooooooooo++~...  .~++oo+::~.                                 ~~++o++:~.   ..~:+ooooooooooooooooooo|
|ooooooooooo++:~.    .:+++o++:~.                             ..~:+++oo+~.   ..~:+oooooooooooooooooooo|
|oooooooooooo++::.   ..~:++oo++::~~~.                   ...~~::+++o++:~~   ..~:+++ooooooooooooooooooo|
|ooooooooooooo+++~.    ..::+oo+o++++:~.                .~::+++oo++++:~.    .:++o+oooooooooooooooooooo|
|ooooooooooooooo+:~.     .~:++ooooo++:~.              .~:+o+oooo++:~..    .~:++oooooooooooooooooooooo|
|ooooooooooooooo++::~.    .~~:++ooooo+:.              .:++oooo++:~~.    ..~:+oooooooooooooooooooooooo|
|ooooooooooooooooo++::.      .~~::+++:~.              .~++o+::~~..     .~:++ooooooooooooooooooooooooo|
|ooooooooooooooooooo++:..       .~::::~.              .~:::~~..      .~:++ooooooooooooooooooooooooooo|
|oooooooooooooooooooo+++:~~..     ....                  ....      ..~~:++oooooooooooooooooooooooooooo|
|ooooooooooooooooooooooo+++:~~.                                ..~:++oooooooooooooooooooooooooooooooo|
|ooooooooooooooooooooooooo+++:~~~....                     ...~~::++++oooooooooooooooooooooooooooooooo|
|ooooooooooooooooooooooooooooo+++++::~~....   .   .....~~:::+++oooooooooooooooooooooooooooooooooooooo|
|ooooooooooooooooooooooooooooooooo+++++::::~:~:~::~:::::++++ooooooooooooooooooooooooooooooooooooooooo|
|ooooooooooooooooooooooooooooooooooooo+oo+oo+o++o+oo+oooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
+----------------------------------------------------------------------------------------------------+
 => nil

or make it thinner

require 'asciiart'
a = AsciiArt.new("https://f.cloud.github.com/assets/54012/36827/2081922c-5377-11e2-9e39-3fafca0cdb79.png")
  => #<AsciiArt:0x007fa889cbacf8 @data="...">


print a.to_ascii_art(width: 50)
+--------------------------------------------------+
|oooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooo===++++====ooooooooooooooooooooo|
|ooooooooooooo=+:~.~........~~~:+=ooooooooooooooooo|
|oooooooooo==:~...~~:++++++:~~..~~:+=oooooooooooooo|
|oooooooo=+:...~++====oooo====+:~..~:+=oooooooooooo|
|ooooooo=+~..~:++==ooooooooooo=++:~..~+=ooooooooooo|
|oooooo=+~.~:+=+~.~~~~~~~~:~~~.~:++:~.~+=oooooooooo|
|ooooo=+~~.+===~................~+==:.~~+=ooooooooo|
|ooooo=:~~:+=+:~................~~+=+:~.:=ooooooooo|
|ooooo=~.~+==+~...................+==+~.:=ooooooooo|
|ooooo=~~~+==:~...................:==+~.:=ooooooooo|
|ooooo=~~~:==+~..................~+==+~.~=ooooooooo|
|ooooo=:~~~+=++~.................:+=+~~~:=ooooooooo|
|ooooo=+:..~+==+~~...........~~~+==+~..:+=ooooooooo|
|ooooooo+:..~:+=o=+:........:+====:~.~:==oooooooooo|
|oooooooo=+~.~~:+==+~......~+==+:~..~:+oooooooooooo|
|ooooooooo=+:~..~~:~~.......~:~~..~:+oooooooooooooo|
|oooooooooooo=+~~..............~:+=oooooooooooooooo|
|ooooooooooooooo==++:~~~~~~:++==ooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooooooooooooooooooooooooooooo|
+--------------------------------------------------+

Add color with the "color" option

require 'asciiart'
a = AsciiArt.new("http://www.evangogh.org/images/paintings/self-portrait.jpg")
  => #<AsciiArt:0x007fa889cbacf8 @data="...">

puts a.to_ascii_art(color: true) =>

Booyah!

In The Command Line

Local Files

$ asciiart ~/Desktop/uncle_larry.jpg

Remote Images

$ asciiart http://www.google.com/images/srpr/logo3w.png

Output it as HTML

$ asciiart -c -f html ~/Ross/cppsource/secret/noopen/sillhere?/turnback/bea-arthur-birthdaysuit.jpg > ~/Desktop/ascii-as-html.html

or smaller

$ asciiart -w 50 -c -f html ~/Stephen/boringSQLsnippets/nothingtoseehere/turnback/bea-arthur-with-ross's-head.jpg > ~/Desktop/saturdaynight.html

Get Help

$ asciiart -h

Usage: asciiart [options] <path_or_url>
  -w, --width WIDTH                Width of the finished Ascii Art (Default: 100)
  -f, --format [text/html]         output format (Default: text)
  -c, --color                      Switch to use colored terminal output (Default: false)
  -i, --invert-chars               Invert the character map. *Depending on background and image color - this can make the result clearer.*
  -v, --version                    Show AsciiArt version
  -h, --help                       Show this message

Requirements

This app requires Ruby 1.9

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

asciiart's People

Contributors

endurantgames avatar nodanaonlyzuul avatar rosscooperman avatar wendy0402 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asciiart's Issues

Deprecated requirement

W: require 'RMagick' is deprecated, please change to require 'rmagick'

(In the debian testing package)

Issue with Gem Installation

Receive the following error...

ERROR: Error installing asciiart:
ERROR: Failed to build gem native extension.

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

When I check the mkfile log I get the following:

assert_minimum_ruby_version!: checking for Ruby version >= 2.3.0... -------------------- yes


find_executable: checking for magick... -------------------- no


find_executable: checking for identify... -------------------- no


Piping coloured output to less removes color escape sequences

Example use:

asciiart lena.jpg -c | less -R

Running the command without piping results in a beautiful coloured asciiart image in the terminal.
However, when piping is performed, only a normal monochromatic asciiart is generated, even though less is called with the -R command which would otherwise have enabled interpretation of escape sequences relating to colour.

In my opinion, the -c option should force outputting escape sequences and attempt no detection of color ability from the terminal, so that this choice is left up to the user.

Support other transformation character sets

We use one from http://www.rubyquiz.com/quiz50.html with some minor changes that make the ASCII version look "meatier".

  def to_ascii
    chars = ['W', 'M', '$', '@', '#', '%', '^', 'x', '*', 'o', '=', '+', ':', '~', '.', ' ']
    font_rows = 6
    font_cols = 3
    image.manipulate_stored_image! do |himage|
      pr = himage.rows / font_rows
      pc = himage.columns / font_cols
      himage.resize!(pc, pr)
      himage = himage.quantize(16, Magick::GRAYColorspace).normalize
      ascii = ""
      border = '+' + ('-' * pc) + '+'
      ascii += border
      ascii += "\r\n"
      himage.view(0, 0, pc, pr) do |view|
        pr.times do |i|
          ascii += '|'
          pc.times { |j|
            ascii += chars[view[i][j].red % 16]
          }
          ascii += "|\r\n"
        end
      end
      ascii += border
      ascii
    end
  end

I think it produces better results, compare image from http://artsy.net/artwork/andy-warhol-skull.

Yours

Ours

You can try the Konami code on that artwork page or http://artsy.net/api/v1/artwork/andy-warhol-skull.txt after logging in :)

undefined method `color' for " ":String

I'm getting this error when I use the -c flag on any image

2.1.1 (main):0 > a = AsciiArt.new('http://image.blingee.com/images18/content/output/000/000/000/78a/745199018_285136.gif')
=> #<AsciiArt>
2.1.1 (main):0 > puts a.to_ascii_art(color: true)
NoMethodError: undefined method `color' for " ":String
from /Users/ryan/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/asciiart-0.0.7/lib/asciiart.rb:57:in `block (3 levels) in to_ascii_art'

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

  spec.license = 'MIT'
  # or
  spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

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.