imaginizer 0.0.3 → 0.0.4
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/lib/imaginizer/image.rb +20 -20
- data/lib/imaginizer/parser.rb +12 -12
- data/lib/imaginizer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de494832c870f1af6fe744725bde17584a1af420
|
4
|
+
data.tar.gz: fae5df7e05998921daf031b480d5e87865aafcfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69201581fdfa70b2b0b16afd4a3705a0bba1d4e0690f36acd50aad266b54721180486be1dc45167d680c307bb761bd4159239827355f6dedb8db8cf2102af1df
|
7
|
+
data.tar.gz: ba25e0f37d499d2768a8aef54827fd1e796b9e398a0fb5bd0ea783eed2501d880335205755352871d13cedba0faf9c8558502455053d5267123c0d91c41be826
|
data/lib/imaginizer/image.rb
CHANGED
@@ -20,36 +20,36 @@ class Imaginizer::Image
|
|
20
20
|
@image_data.format 'jpg'
|
21
21
|
end
|
22
22
|
|
23
|
-
def resize
|
24
|
-
@image_data.resize "#{
|
23
|
+
def resize(w = image_width, h = image_height)
|
24
|
+
@image_data.resize "#{w}x#{h}!"
|
25
25
|
end
|
26
26
|
|
27
|
-
def set_background(
|
27
|
+
def set_background(path_or_url)
|
28
28
|
v = values_for :background
|
29
|
-
overlay_image
|
30
|
-
y: v[:y], h: v[:h]
|
29
|
+
overlay_image img: path_or_url, blur: '0x15', fill: true, x: v[:x],
|
30
|
+
y: v[:y], h: v[:h]
|
31
31
|
end
|
32
32
|
|
33
|
-
def set_foreground(
|
33
|
+
def set_foreground(path_or_url)
|
34
34
|
v = values_for :foreground
|
35
|
-
overlay_image
|
35
|
+
overlay_image img: path_or_url, h: v[:h], w: v[:w] unless v[:skip]
|
36
36
|
end
|
37
37
|
|
38
|
-
def set_title(
|
39
|
-
set_text :title,
|
38
|
+
def set_title(text)
|
39
|
+
set_text :title, text do |v|
|
40
40
|
{style: 'bold', uppercase: true, x: v[:x], y: v[:y], size: v[:size]}
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
def set_subtitle(
|
45
|
-
set_text :subtitle,
|
44
|
+
def set_subtitle(text)
|
45
|
+
set_text :subtitle, text do |v|
|
46
46
|
{style: 'italic', size: 14, x: v[:x], y: v[:y]}
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
def set_footer(
|
50
|
+
def set_footer(text)
|
51
51
|
overlay_box values_for(:footer)
|
52
|
-
set_text :footer,
|
52
|
+
set_text :footer, text do |v|
|
53
53
|
{style: 'bold', uppercase: true, x: v[:x], y: v[:y], size: v[:size]}
|
54
54
|
end
|
55
55
|
end
|
@@ -128,15 +128,15 @@ private
|
|
128
128
|
values_for :height
|
129
129
|
end
|
130
130
|
|
131
|
-
def set_text(size,
|
131
|
+
def set_text(size, text)
|
132
132
|
values = values_for size
|
133
|
-
|
133
|
+
options = {text: text}.merge yield(values)
|
134
134
|
if values[:second_line_y]
|
135
135
|
line1, line2 = word_wrap options[:text]
|
136
|
-
overlay_text
|
137
|
-
overlay_text
|
136
|
+
overlay_text options.merge(text: line1)
|
137
|
+
overlay_text options.merge(text: line2, y: values[:second_line_y])
|
138
138
|
else
|
139
|
-
overlay_text
|
139
|
+
overlay_text options
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
@@ -146,7 +146,7 @@ private
|
|
146
146
|
|
147
147
|
def overlay_text(options = {})
|
148
148
|
return unless text = options[:text]
|
149
|
-
text.upcase
|
149
|
+
text = text.upcase if options[:uppercase]
|
150
150
|
@image_data.combine_options do |c|
|
151
151
|
c.fill 'white'
|
152
152
|
c.font font_path(options[:style])
|
@@ -174,7 +174,7 @@ private
|
|
174
174
|
image.blur options[:blur]
|
175
175
|
|
176
176
|
image.crop options
|
177
|
-
image.resize
|
177
|
+
image.resize image_width, image_height if options[:fill]
|
178
178
|
overlay_x = options[:x] || 0
|
179
179
|
overlay_y = options[:y] || 0
|
180
180
|
@image_data = @image_data.composite image.image_data do |c|
|
data/lib/imaginizer/parser.rb
CHANGED
@@ -20,29 +20,29 @@ class Imaginizer::Parser
|
|
20
20
|
options[:sizes] << d
|
21
21
|
end
|
22
22
|
|
23
|
-
opts.on('-b', '--background
|
23
|
+
opts.on('-b', '--background path_or_url', String,
|
24
24
|
%q(Background image – either a local path or a URL)) do |path|
|
25
|
-
options[:background]
|
25
|
+
options[:background] = path
|
26
26
|
end
|
27
27
|
|
28
|
-
opts.on('-f', '--foreground
|
28
|
+
opts.on('-f', '--foreground path_or_url', String,
|
29
29
|
%q(Foreground image – either a local path or a URL)) do |path|
|
30
|
-
options[:foreground]
|
30
|
+
options[:foreground] = path
|
31
31
|
end
|
32
32
|
|
33
33
|
opts.on('-t', '--title text', String,
|
34
34
|
%q(Title to overlay – maximum 15 characters)) do |text|
|
35
|
-
options[:title]
|
35
|
+
options[:title] = text
|
36
36
|
end
|
37
37
|
|
38
38
|
opts.on('-s', '--subtitle text', String,
|
39
39
|
%q(Subtitle to overlay – maximum 15 characters)) do |text|
|
40
|
-
options[:subtitle]
|
40
|
+
options[:subtitle] = text
|
41
41
|
end
|
42
42
|
|
43
43
|
opts.on('-r', '--footer text', String,
|
44
44
|
%q(Footer to overlay – maximum 20 characters)) do |text|
|
45
|
-
options[:footer]
|
45
|
+
options[:footer] = text
|
46
46
|
end
|
47
47
|
|
48
48
|
opts.on('-o', '--output [OUTPUT]', [:image, :html],
|
@@ -74,11 +74,11 @@ class Imaginizer::Parser
|
|
74
74
|
{}.tap do |opts|
|
75
75
|
opts[:output] = :html
|
76
76
|
opts[:sizes] = []
|
77
|
-
opts[:title] =
|
78
|
-
opts[:subtitle] =
|
79
|
-
opts[:footer] =
|
80
|
-
opts[:background] =
|
81
|
-
opts[:foreground] =
|
77
|
+
opts[:title] = 'Title max 18 chars'
|
78
|
+
opts[:subtitle] = 'This subtitle is 30 characters'
|
79
|
+
opts[:footer] = 'A footer w/ 20 chars'
|
80
|
+
opts[:background] = 'http://lorempixel.com/300/300/abstract'
|
81
|
+
opts[:foreground] = 'http://lorempixel.com/300/300/people'
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
data/lib/imaginizer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imaginizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Baccigalupo
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mini_magick
|