ImageText 1.0.0 → 1.0.1
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 +4 -4
- data/bin/imagetext +1 -1
- data/lib/ImageText.rb +10 -9
- data/lib/helpers.rb +6 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d924657e1da6e209fcda3cb13723a5299ecf4678
|
4
|
+
data.tar.gz: 3b9a3881073813fa0688a699d67398b99d1c26ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83b4d2a3a60d5af469a11ecb455fd1649c175c06e919817444ba073cda30c4275a132f9bc1b1cc196686ea5686f3e22c1f6ffd7d811997cfadba7cf83049169e
|
7
|
+
data.tar.gz: f2879f743d3931d98a3eaa862caf153e513c83aa95a28b3dbbbf4f928eeaafbc2455e1478083e8899236ef00aa56de0e98e3daea11eed7a3d1a1ea6c3b4d6472
|
data/bin/imagetext
CHANGED
data/lib/ImageText.rb
CHANGED
@@ -4,30 +4,31 @@ require 'helpers.rb'
|
|
4
4
|
include Magick
|
5
5
|
|
6
6
|
class ImageText
|
7
|
-
@@chars = " .,-_
|
7
|
+
@@chars = " .,-_\"*^+=|?$&%Q@\#"
|
8
8
|
@@maxchar = @@chars.length - 1
|
9
9
|
|
10
10
|
def initialize(image, max_width=150.0)
|
11
|
-
|
12
|
-
|
11
|
+
panic "File not found" if not File.exist?(image)
|
12
|
+
begin
|
13
|
+
@img = ImageList.new(image).average
|
14
|
+
rescue
|
15
|
+
panic "Could not load image!"
|
16
|
+
end
|
13
17
|
|
14
18
|
scale = [(max_width.to_f / @img.columns), 1.0].min
|
15
19
|
@img.scale!(scale)
|
16
20
|
end
|
17
21
|
|
18
|
-
def texify()
|
22
|
+
def texify(breakline = "\n")
|
19
23
|
text = ""
|
20
24
|
@img.each_pixel do
|
21
25
|
|pixel, x, y|
|
22
26
|
|
23
|
-
text +=
|
27
|
+
text += breakline if (x == @img.columns - 1)
|
24
28
|
|
25
29
|
colour = pixel.to_color(AllCompliance, false, QuantumDepth, true)
|
26
|
-
|
27
30
|
gScale = gray_scale(colour);
|
28
|
-
|
29
|
-
#puts gScale
|
30
|
-
#puts ((@@chars.length) * gScale)
|
31
|
+
|
31
32
|
text += @@chars[(@@maxchar * gScale).round]
|
32
33
|
|
33
34
|
end
|
data/lib/helpers.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ImageText
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arsham
|
@@ -38,7 +38,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
requirements:
|
41
|
+
requirements:
|
42
|
+
- libmagicdev, RMagick
|
42
43
|
rubyforge_project:
|
43
44
|
rubygems_version: 2.0.14
|
44
45
|
signing_key:
|