ascmaster 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2a874251112cb9380286ad1946efff63b4599f14
4
+ data.tar.gz: c00839b9527b3053d925029abc8f529a54eca2e5
5
+ SHA512:
6
+ metadata.gz: 03f9634aecedcf370177aa35f68bd1883867392b1c0a23473e630ceab268443c7d1078e3715f40041d20ac79f7131af8d1338f64b291b94c28bc454b3277cacb
7
+ data.tar.gz: 34a0e109ad4b73131bd4d6d9e60ede62cc741d187284178345c1b4818d5f74898b6f9758ec51deb6344d62423acd13d5f7a9d444dc1adc9d4fe05de230144b1a
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *.jpg
2
+ .DS_Store
3
+ *.gem
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p353
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gem 'rmagick'
3
+ gem 'debugger'
data/Gemfile.lock ADDED
@@ -0,0 +1,18 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ columnize (0.3.6)
5
+ debugger (1.6.6)
6
+ columnize (>= 0.3.1)
7
+ debugger-linecache (~> 1.2.0)
8
+ debugger-ruby_core_source (~> 1.3.2)
9
+ debugger-linecache (1.2.0)
10
+ debugger-ruby_core_source (1.3.2)
11
+ rmagick (2.13.2)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ debugger
18
+ rmagick
data/README.md ADDED
@@ -0,0 +1,15 @@
1
+ ascmaster
2
+ =========
3
+
4
+ ascmaster is a simple Ruby gem for converting images to ASCII.
5
+
6
+ Unfortunately it has the worst dependency in the world: rmagick.
7
+
8
+ To install: ````gem install ascmaster````
9
+
10
+ Or, if you're using Bundler, add to your Gemfile: ````gem 'ascmaster'````
11
+
12
+ You can use ascmaster from the command-line. Just give it the path to a local image file:
13
+ ```ascmaster path/to/your/image.jpg```
14
+
15
+ Enjoy!
data/ascmaster.gemspec ADDED
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'ascmaster'
3
+ s.version = '0.0.0'
4
+ s.date = '2014-07-12'
5
+ s.summary = "Convert an image to ASCII art"
6
+ s.description = "Ascmaster converts images to ASCII characters."
7
+ s.authors = ["Devin Riley"]
8
+ s.email = 'devinriley84@gmail.com'
9
+ s.files = `git ls-files`.split($\)
10
+ s.executables = ["ascmaster"]
11
+ s.require_paths = ["lib"]
12
+ s.homepage = 'http://rubygems.org/gems/ascmaster'
13
+ s.license = 'MIT'
14
+ end
data/bin/ascmaster ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ascmaster'
4
+
5
+ raise "You must provide a file to convert!" unless ARGV[0]
6
+ filename = ARGV[0]
7
+ width = ARGV[1] ? ARGV[1].to_i : 100
8
+ Ascmaster::ImgToAsciiConverter.convert(filename, width)
9
+ exit
data/lib/ascmaster.rb ADDED
@@ -0,0 +1,2 @@
1
+ #!/bin/env/ruby
2
+ require 'ascmaster/img_to_ascii_converter'
@@ -0,0 +1,44 @@
1
+ #!/bin/env/ruby
2
+ require 'rmagick'
3
+ include Magick
4
+
5
+ module Ascmaster
6
+ class ImgToAsciiConverter
7
+ ASCII_CHARS = ' ˙.:i|#◙'
8
+
9
+ class << self
10
+ def image_to_ascii(image)
11
+ ascii = []
12
+ image.each_pixel do |pixel|
13
+ scaled_pixel = pixel.intensity.to_f / MaxRGB
14
+ ascii << ASCII_CHARS[((ASCII_CHARS.length - 1) * scaled_pixel).round]
15
+ end
16
+ return ascii
17
+ end
18
+
19
+ def make_grayscale(image)
20
+ image.quantize(256, Magick::GRAYColorspace)
21
+ end
22
+
23
+ def scale(image, width)
24
+ image = image.scale(width / image.columns.to_f)
25
+ image.scale(image.columns, image.rows / 2.3)
26
+ end
27
+
28
+ def print_ascii(ascii, width)
29
+ ascii.each_with_index do |char, index|
30
+ print char
31
+ print "\n" if index % width == 0
32
+ end
33
+ end
34
+
35
+ def convert(image_name, width = 70)
36
+ image = ImageList.new(image_name)
37
+ scaled_image = scale(image, width)
38
+ grayscale = make_grayscale(scaled_image)
39
+ ascii = image_to_ascii(grayscale)
40
+ print_ascii(ascii, width)
41
+ end
42
+ end
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ascmaster
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Devin Riley
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ascmaster converts images to ASCII characters.
14
+ email: devinriley84@gmail.com
15
+ executables:
16
+ - ascmaster
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - .gitignore
21
+ - .ruby-version
22
+ - Gemfile
23
+ - Gemfile.lock
24
+ - README.md
25
+ - ascmaster.gemspec
26
+ - bin/ascmaster
27
+ - lib/ascmaster.rb
28
+ - lib/ascmaster/img_to_ascii_converter.rb
29
+ homepage: http://rubygems.org/gems/ascmaster
30
+ licenses:
31
+ - MIT
32
+ metadata: {}
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 2.0.14
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Convert an image to ASCII art
53
+ test_files: []