asciiart 0.0.5 → 0.0.10

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
+ SHA256:
3
+ metadata.gz: 3a8d99e878fcb702b5c8c0fa998f6d3b942f90d19b20e30f6f7f2eff8bce0f88
4
+ data.tar.gz: 7eef461cb0b54d2eefb6eac93ea8fc74b846251936b752b2ffcd557ad210e477
5
+ SHA512:
6
+ metadata.gz: 55ac4320bbe7724f765aa492971d890ccb87f079fd544e884df925c48f94df253dd6c2760ba1289bf595434feb9fea3ffbc9e7c6bfde931cc176b048c3a272c5
7
+ data.tar.gz: 65ad4c44c57a1d24cfff039a6b63457c7a9528d7c279e1c37710bdca7de7e41fe56f67d02fc555df95bf5759efa81b6100f2adda286501e06fd6ff2f16bd67ec
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # AsciiArt By:
1
+ # Developed At:
2
2
 
3
3
  +----------------------------------------------------------------------------------------------------+
4
4
  |oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
@@ -151,16 +151,29 @@ Remote Images
151
151
 
152
152
  $ asciiart http://www.google.com/images/srpr/logo3w.png
153
153
 
154
+ Output it as HTML
155
+
156
+ $ asciiart -c -f html ~/Ross/cppsource/secret/noopen/sillhere?/turnback/bea-arthur-birthdaysuit.jpg > ~/Desktop/ascii-as-html.html
157
+
158
+ _or smaller_
159
+
160
+ $ asciiart -w 50 -c -f html ~/Stephen/boringSQLsnippets/nothingtoseehere/turnback/bea-arthur-with-ross's-head.jpg > ~/Desktop/saturdaynight.html
161
+
154
162
  Get Help
155
163
 
156
164
  $ asciiart -h
157
165
 
158
166
  Usage: asciiart [options] <path_or_url>
159
- -w, --width WIDTH Width of the finished Ascii Art (Default: 100)
160
- -c, --color Switch to use colored terminal output (Default: false)
161
- -i, --invert-chars Invert the character map. Depending on your terminal and image this can make the image clearer (or a lot worse)
162
- -v, --version Show AsciiArt version
163
- -h, --help Show this message
167
+ -w, --width WIDTH Width of the finished Ascii Art (Default: 100)
168
+ -f, --format [text/html] output format (Default: text)
169
+ -c, --color Switch to use colored terminal output (Default: false)
170
+ -i, --invert-chars Invert the character map. *Depending on background and image color - this can make the result clearer.*
171
+ -v, --version Show AsciiArt version
172
+ -h, --help Show this message
173
+
174
+ ## Requirements
175
+
176
+ This app requires Ruby 1.9
164
177
 
165
178
  ## Contributing
166
179
 
data/asciiart.gemspec CHANGED
@@ -6,19 +6,19 @@ require 'asciiart/version'
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "asciiart"
8
8
  gem.version = AsciiArt::VERSION
9
- gem.authors = ["nodanaonlyzuul", "rosscooperman"]
9
+ gem.authors = ["nodanaonlyzuul", "rosscooperman", "caderaspindrift"]
10
10
  gem.email = ["stephen@eastmedia.com"]
11
11
  # gem.description = %q{A command line tool to turn images into ASCII art}
12
12
  gem.summary = %q{A command line tool to turn images into ASCII art}
13
- gem.homepage = "https://github.com/eastmedia/asciiart"
13
+ gem.homepage = "https://github.com/nodanaonlyzuul/asciiart"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.add_dependency('rmagick')
21
- gem.add_dependency('rainbow')
20
+ gem.add_dependency('rmagick', '2.13.4')
21
+ gem.add_dependency('rainbow', '2.0.0')
22
22
 
23
23
  gem.add_development_dependency('pry')
24
24
  end
data/bin/asciiart CHANGED
@@ -13,6 +13,10 @@ opt_parser = OptionParser.new do |opts|
13
13
  options[:width] = width.to_i
14
14
  end
15
15
 
16
+ opts.on('-f', '--format [text/html]', 'output format (Default: text)') do |format|
17
+ options[:format] = format
18
+ end
19
+
16
20
  opts.on('-c', '--color', 'Switch to use colored terminal output (Default: false)') do
17
21
  options[:color] = true
18
22
  end
data/lib/asciiart.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require "asciiart/version"
2
- require 'RMagick'
2
+ require 'rmagick'
3
3
  require 'uri'
4
4
  require 'open-uri'
5
5
  require 'rainbow'
6
+ require 'rainbow/ext/string'
6
7
 
7
8
  class AsciiArt
8
9
 
@@ -15,7 +16,7 @@ class AsciiArt
15
16
  end
16
17
 
17
18
  def to_ascii_art(options = {})
18
- options = { width: 100, color: false }.merge(options)
19
+ options = { width: 100, color: false, format: "text" }.merge(options)
19
20
 
20
21
  img = Magick::Image.from_blob(@data).first
21
22
 
@@ -27,8 +28,11 @@ class AsciiArt
27
28
  color_image = img.dup if options[:color]
28
29
  img = img.quantize(image_chars.length, Magick::GRAYColorspace).normalize
29
30
  quantum_calc = Magick::QuantumRange / Magick::QuantumPixel.to_i
31
+ image_chars.map! {|char| char == " " ? "&nbsp;" : char } if options[:format] == "html"
32
+
33
+ border = "+#{'-' * width}+#{line_break(options[:format])}"
34
+ border = html_char(border) if options[:format] == "html"
30
35
 
31
- border = "+#{'-' * width}+\n"
32
36
  output = border.dup
33
37
 
34
38
  img.view(0, 0, width, height) do |view|
@@ -38,14 +42,27 @@ class AsciiArt
38
42
 
39
43
  character = image_chars[view[i][j].red/quantum_calc]
40
44
 
41
- if options[:color]
42
- pix = color_image.pixel_color(j,i)
43
- character = character.color(unified_rgb_value(pix.red), unified_rgb_value(pix.green), unified_rgb_value(pix.blue))
45
+ if options[:format] == "html"
46
+ if (options[:color])
47
+
48
+ pix = color_image.pixel_color(j,i)
49
+ color_string = "color: #{pix.to_color( Magick::AllCompliance,false,8, true)};"
50
+ else
51
+ color_string = ""
52
+ end
53
+ character = html_char(character, color_string)
54
+ else
55
+ # text-format
56
+ if options[:color]
57
+ pix = color_image.pixel_color(j,i)
58
+ character = character.color(unified_rgb_value(pix.red), unified_rgb_value(pix.green), unified_rgb_value(pix.blue))
59
+ end
44
60
  end
45
61
 
46
62
  output << character
47
63
  end
48
- output << "|\n"
64
+
65
+ output << "|#{line_break(options[:format])}"
49
66
  end
50
67
  end
51
68
 
@@ -62,9 +79,20 @@ class AsciiArt
62
79
 
63
80
  private
64
81
 
82
+ def line_break(format)
83
+ (format == "text") ? "\n" : "<br/>"
84
+ end
85
+
65
86
  def unified_rgb_value(number)
66
- (Magick::QuantumDepth == 16) ? (number / 256) : number
87
+ if defined?(Magick::QuantumDepth)
88
+ return (Magick::QuantumDepth == 16) ? (number / 256) : number
89
+ else
90
+ return (Magick::QuantumRange == 65535) ? (number / 256) : number
91
+ end
67
92
  end
68
93
 
94
+ def html_char(char, additional_style = "")
95
+ "<span style=\"font-family: 'Lucida Console', Monaco, monospace; #{additional_style}\">#{char}</span>"
96
+ end
69
97
  end
70
98
 
@@ -1,3 +1,3 @@
1
1
  class AsciiArt
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.10"
3
3
  end
metadata CHANGED
@@ -1,66 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciiart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
5
- prerelease:
4
+ version: 0.0.10
6
5
  platform: ruby
7
6
  authors:
8
7
  - nodanaonlyzuul
9
8
  - rosscooperman
10
- autorequire:
9
+ - caderaspindrift
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-28 00:00:00.000000000 Z
13
+ date: 2021-02-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rmagick
17
17
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
18
  requirements:
20
- - - ! '>='
19
+ - - '='
21
20
  - !ruby/object:Gem::Version
22
- version: '0'
21
+ version: 2.13.4
23
22
  type: :runtime
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
25
  requirements:
28
- - - ! '>='
26
+ - - '='
29
27
  - !ruby/object:Gem::Version
30
- version: '0'
28
+ version: 2.13.4
31
29
  - !ruby/object:Gem::Dependency
32
30
  name: rainbow
33
31
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
32
  requirements:
36
- - - ! '>='
33
+ - - '='
37
34
  - !ruby/object:Gem::Version
38
- version: '0'
35
+ version: 2.0.0
39
36
  type: :runtime
40
37
  prerelease: false
41
38
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
39
  requirements:
44
- - - ! '>='
40
+ - - '='
45
41
  - !ruby/object:Gem::Version
46
- version: '0'
42
+ version: 2.0.0
47
43
  - !ruby/object:Gem::Dependency
48
44
  name: pry
49
45
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
46
  requirements:
52
- - - ! '>='
47
+ - - ">="
53
48
  - !ruby/object:Gem::Version
54
49
  version: '0'
55
50
  type: :development
56
51
  prerelease: false
57
52
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
53
  requirements:
60
- - - ! '>='
54
+ - - ">="
61
55
  - !ruby/object:Gem::Version
62
56
  version: '0'
63
- description:
57
+ description:
64
58
  email:
65
59
  - stephen@eastmedia.com
66
60
  executables:
@@ -68,7 +62,7 @@ executables:
68
62
  extensions: []
69
63
  extra_rdoc_files: []
70
64
  files:
71
- - .gitignore
65
+ - ".gitignore"
72
66
  - Gemfile
73
67
  - LICENSE.txt
74
68
  - README.md
@@ -77,28 +71,26 @@ files:
77
71
  - bin/asciiart
78
72
  - lib/asciiart.rb
79
73
  - lib/asciiart/version.rb
80
- homepage: https://github.com/eastmedia/asciiart
74
+ homepage: https://github.com/nodanaonlyzuul/asciiart
81
75
  licenses: []
82
- post_install_message:
76
+ metadata: {}
77
+ post_install_message:
83
78
  rdoc_options: []
84
79
  require_paths:
85
80
  - lib
86
81
  required_ruby_version: !ruby/object:Gem::Requirement
87
- none: false
88
82
  requirements:
89
- - - ! '>='
83
+ - - ">="
90
84
  - !ruby/object:Gem::Version
91
85
  version: '0'
92
86
  required_rubygems_version: !ruby/object:Gem::Requirement
93
- none: false
94
87
  requirements:
95
- - - ! '>='
88
+ - - ">="
96
89
  - !ruby/object:Gem::Version
97
90
  version: '0'
98
91
  requirements: []
99
- rubyforge_project:
100
- rubygems_version: 1.8.24
101
- signing_key:
102
- specification_version: 3
92
+ rubygems_version: 3.0.8
93
+ signing_key:
94
+ specification_version: 4
103
95
  summary: A command line tool to turn images into ASCII art
104
96
  test_files: []