File tree Expand file tree Collapse file tree 3 files changed +65
-5
lines changed Expand file tree Collapse file tree 3 files changed +65
-5
lines changed Original file line number Diff line number Diff line change 1
1
# ascii-image
2
2
3
- A Ruby library to convert images into ASCII.
3
+ A Ruby gem to convert images into ASCII for your awesome command-line applications.
4
+ * This is my first Ruby gem*
5
+
6
+
7
+ ## Example
8
+
9
+ Convert an image to ASCII and print it using 20 columns of the console:
10
+
11
+ ascii = ASCII_Image.new("file.jpg")
12
+ ascii.build(20)
13
+
14
+
15
+ ## License
16
+
17
+ This library is licensed under the GPLv3 license.
18
+
19
+ > ascii-image - A Ruby gem to convert images into ASCII.
20
+ > Copyright (C) 2012 Nathan Campos
21
+ >
22
+ > This program is free software: you can redistribute it and/or modify
23
+ > it under the terms of the GNU General Public License as published by
24
+ > the Free Software Foundation, either version 3 of the License, or
25
+ > (at your option) any later version.
26
+ >
27
+ > This program is distributed in the hope that it will be useful,
28
+ > but WITHOUT ANY WARRANTY; without even the implied warranty of
29
+ > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
+ > GNU General Public License for more details.
31
+ >
32
+ > You should have received a copy of the GNU General Public License
33
+ > along with this program. If not, see < http://www.gnu.org/licenses/ > .
Original file line number Diff line number Diff line change 1
1
Gem ::Specification . new do |s |
2
2
s . name = "ascii-image"
3
- s . version = "0.0.1 "
4
- s . date = '2012-11-03 '
3
+ s . version = "0.1.0 "
4
+ s . date = '2012-11-04 '
5
5
s . summary = "Convert images into ASCII"
6
- s . description = "A Ruby gem to convert images into ASCII"
6
+ s . description = "A Ruby gem to convert images into ASCII for your awesome command-line applications "
7
7
s . authors = [ "Nathan Campos" ]
8
8
s . email = "nathanpc@dreamintech.net"
9
9
s . files = [ "lib/ascii-image.rb" ]
10
10
s . homepage = "https://github.com/nathanpc/ascii-image"
11
- end
11
+ end
Original file line number Diff line number Diff line change 4
4
require 'RMagick'
5
5
require 'rainbow'
6
6
7
+ # == Summary
8
+ #
9
+ # This handy Ruby gem will help you to create awesome ASCII art from images
10
+ # for your awesome command-line projects.
11
+ #
12
+ # == Example
13
+ #
14
+ # ascii = ASCII_Image.new("file.jpg")
15
+ # ascii.build(80)
16
+ #
17
+ # == Contact
18
+ #
19
+ # Author:: Nathan Campos (nathanpc@dreamintech.net)
20
+ # Website:: http://about.me/nathanpc
21
+
7
22
class ASCII_Image
23
+ # Initialize the ASCII_Image class.
24
+ #
25
+ # An Error is raised if your ImageMagick quantum depth is higher than 8.
26
+ #
27
+ # Arguments:
28
+ # file: (String)
29
+ # console_width: (Integer)
30
+
8
31
def initialize ( file , console_width = 80 )
9
32
@file = file
10
33
@console_width = console_width
@@ -14,6 +37,13 @@ def initialize(file, console_width = 80)
14
37
end
15
38
end
16
39
40
+ # Convert the image into ASCII and print it to the console.
41
+ #
42
+ # An ArgumentError is raised if the +width+ is bigger than the +console_width+
43
+ #
44
+ # Arguments:
45
+ # width: (Integer)
46
+
17
47
def build ( width )
18
48
# Open the image file
19
49
image = Magick ::Image . read ( @file ) [ 0 ]
You can’t perform that action at this time.
0 commit comments