imaginizer 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82ba111cb40bc4ffde4bb54212a371ce849b7876
4
- data.tar.gz: ec933dd1678bf6ee211d9989fb5fac39e4c8ad16
3
+ metadata.gz: de494832c870f1af6fe744725bde17584a1af420
4
+ data.tar.gz: fae5df7e05998921daf031b480d5e87865aafcfb
5
5
  SHA512:
6
- metadata.gz: 286af7a8402b9a6b55737b36bc39be6ddf5b371bb02741f65660bdc10f371e85af9e44921b5d5dc5dfa40abec54ecd0f660733f8bacde92414aa9ab93e25295e
7
- data.tar.gz: 378ccaf62c45a887f1f1cf7d8ab9c8855d46dd546caf6fce19429ee42ed0275044827a4f70d2b3ca4bd82715dd778d68bbb9f626700d63550a561c68624a863e
6
+ metadata.gz: 69201581fdfa70b2b0b16afd4a3705a0bba1d4e0690f36acd50aad266b54721180486be1dc45167d680c307bb761bd4159239827355f6dedb8db8cf2102af1df
7
+ data.tar.gz: ba25e0f37d499d2768a8aef54827fd1e796b9e398a0fb5bd0ea783eed2501d880335205755352871d13cedba0faf9c8558502455053d5267123c0d91c41be826
@@ -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 "#{image_width}x#{image_height}!"
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(options = {})
27
+ def set_background(path_or_url)
28
28
  v = values_for :background
29
- overlay_image options.merge(blur: '0x15', fill: true, x: v[:x],
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(options = {})
33
+ def set_foreground(path_or_url)
34
34
  v = values_for :foreground
35
- overlay_image options.merge(h: v[:h], w: v[:w]) unless v[:skip]
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(options = {})
39
- set_text :title, options do |v|
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(options = {})
45
- set_text :subtitle, options do |v|
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(options = {})
50
+ def set_footer(text)
51
51
  overlay_box values_for(:footer)
52
- set_text :footer, options do |v|
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, options = {})
131
+ def set_text(size, text)
132
132
  values = values_for size
133
- size_options = options.merge yield(values)
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 size_options.merge(text: line1)
137
- overlay_text size_options.merge(text: line2, y: values[:second_line_y])
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 size_options
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! if options[:uppercase]
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 image_size if options[:fill]
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|
@@ -20,29 +20,29 @@ class Imaginizer::Parser
20
20
  options[:sizes] << d
21
21
  end
22
22
 
23
- opts.on('-b', '--background path', String,
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][:img] = path
25
+ options[:background] = path
26
26
  end
27
27
 
28
- opts.on('-f', '--foreground path', String,
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][:img] = path
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][:text] = text
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][:text] = text
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][:text] = text
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] = {text: 'Title max 18 chars'}
78
- opts[:subtitle] = {text: 'This subtitle is 30 characters'}
79
- opts[:footer] = {text: 'A footer w/ 20 chars'}
80
- opts[:background] = {img: 'http://lorempixel.com/300/300/abstract'}
81
- opts[:foreground] = {img: 'http://lorempixel.com/300/300/people'}
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
 
@@ -1,3 +1,3 @@
1
1
  module Imaginizer
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
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.3
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-26 00:00:00.000000000 Z
12
+ date: 2013-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mini_magick