image_resizer 0.2.3 → 0.3.0
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.
- data/README.md +3 -0
- data/VERSION +1 -1
- data/image_resizer.gemspec +2 -2
- data/lib/image_resizer/processor.rb +17 -12
- data/spec/image_resizer/processor_spec.rb +113 -50
- metadata +13 -13
data/README.md
CHANGED
@@ -51,6 +51,9 @@ Example:
|
|
51
51
|
tempfile = processor.generate_icon(temp_object)
|
52
52
|
File.open(path_to_output_file, 'wb') { |f| f.write(File.read(tempfile)) }
|
53
53
|
|
54
|
+
Any of the resizing and cropping methods accept an optional :format option that determines the output format of the file (:png, :jpg, etc.). If omitted, the original file format is maintained.
|
55
|
+
|
56
|
+
|
54
57
|
Credits
|
55
58
|
=======
|
56
59
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/image_resizer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "image_resizer"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Daniel Nelson"]
|
12
|
-
s.date = "2012-04-
|
12
|
+
s.date = "2012-04-30"
|
13
13
|
s.description = "Image resizing gem (requires ImageMagick)"
|
14
14
|
s.email = "daniel@populr.me"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -30,9 +30,9 @@ module ImageResizer
|
|
30
30
|
if height == 0 && width == 0
|
31
31
|
temp_object.file
|
32
32
|
elsif height == 0
|
33
|
-
_resize(temp_object, "#{width}x")
|
33
|
+
_resize(temp_object, "#{width}x", options[:format])
|
34
34
|
elsif width == 0
|
35
|
-
_resize(temp_object, "x#{height}")
|
35
|
+
_resize(temp_object, "x#{height}", options[:format])
|
36
36
|
else
|
37
37
|
if options[:crop_from_top_if_portrait]
|
38
38
|
analyzer = ImageResizer::Analyzer.new
|
@@ -41,12 +41,12 @@ module ImageResizer
|
|
41
41
|
center_of_gravity = 'c'
|
42
42
|
end
|
43
43
|
|
44
|
-
resize_and_crop(temp_object, :width => width.to_i, :height => height.to_i, :gravity => center_of_gravity)
|
44
|
+
resize_and_crop(temp_object, :width => width.to_i, :height => height.to_i, :gravity => center_of_gravity, :format => options[:format])
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
def _resize(temp_object, geometry)
|
49
|
-
convert(temp_object, "-resize #{geometry}")
|
48
|
+
def _resize(temp_object, geometry, format=nil)
|
49
|
+
convert(temp_object, "-resize #{geometry}", format)
|
50
50
|
end
|
51
51
|
|
52
52
|
def auto_orient(temp_object)
|
@@ -66,7 +66,7 @@ module ImageResizer
|
|
66
66
|
resize = opts[:resize] ? "-resize #{opts[:resize]} " : ''
|
67
67
|
gravity = gravity ? "-gravity #{gravity} " : ''
|
68
68
|
|
69
|
-
convert(temp_object, "#{resize}#{gravity}-crop #{width}x#{height}#{x}#{y} #{repage}")
|
69
|
+
convert(temp_object, "#{resize}#{gravity}-crop #{width}x#{height}#{x}#{y} #{repage}", opts[:format])
|
70
70
|
end
|
71
71
|
|
72
72
|
def resize_and_crop_around_point(temp_object, options)
|
@@ -119,7 +119,8 @@ module ImageResizer
|
|
119
119
|
:upper_left => [upper_left_x_percent, upper_left_y_percent],
|
120
120
|
:lower_right => [lower_right_x_percent, lower_right_y_percent],
|
121
121
|
:width => desired_width,
|
122
|
-
:height => desired_height
|
122
|
+
:height => desired_height,
|
123
|
+
:format => options[:format]
|
123
124
|
)
|
124
125
|
end
|
125
126
|
|
@@ -155,7 +156,7 @@ module ImageResizer
|
|
155
156
|
end
|
156
157
|
|
157
158
|
|
158
|
-
convert(temp_object, "-crop #{frame_width}x#{frame_height}+#{upper_left_x}+#{upper_left_y} -resize #{desired_width}x#{desired_height} +repage")
|
159
|
+
convert(temp_object, "-crop #{frame_width}x#{frame_height}+#{upper_left_x}+#{upper_left_y} -resize #{desired_width}x#{desired_height} +repage", options[:format])
|
159
160
|
end
|
160
161
|
|
161
162
|
def flip(temp_object)
|
@@ -173,7 +174,11 @@ module ImageResizer
|
|
173
174
|
|
174
175
|
def resize_and_crop(temp_object, opts={})
|
175
176
|
if !opts[:width] && !opts[:height]
|
176
|
-
|
177
|
+
if opts[:format]
|
178
|
+
return convert(temp_object, '', opts[:format])
|
179
|
+
else
|
180
|
+
return temp_object
|
181
|
+
end
|
177
182
|
elsif !opts[:width] || !opts[:height]
|
178
183
|
attrs = identify(temp_object)
|
179
184
|
opts[:width] ||= attrs[:width]
|
@@ -213,12 +218,12 @@ module ImageResizer
|
|
213
218
|
end
|
214
219
|
|
215
220
|
def convert(temp_object, args='', format=nil)
|
216
|
-
|
221
|
+
super
|
217
222
|
end
|
218
223
|
|
219
224
|
def generate_icon(temp_object, options={})
|
220
225
|
max_resolution = [options[:max_resolution] || 256, 256].min
|
221
|
-
largest_png = convert(temp_object, "-resize #{max_resolution}x#{max_resolution}! -transparent white", :png)
|
226
|
+
largest_png = convert(temp_object, "-resize #{max_resolution}x#{max_resolution}! -transparent white", :png)
|
222
227
|
formats = []
|
223
228
|
current = 16
|
224
229
|
while current < max_resolution
|
@@ -226,7 +231,7 @@ module ImageResizer
|
|
226
231
|
current *= 2
|
227
232
|
end
|
228
233
|
formats << largest_png
|
229
|
-
convert(formats, '', :ico)
|
234
|
+
convert(formats, '', :ico)
|
230
235
|
end
|
231
236
|
end
|
232
237
|
end
|
@@ -75,6 +75,11 @@ describe ImageResizer::Processor do
|
|
75
75
|
|
76
76
|
describe "crop" do # Difficult to test here other than dimensions
|
77
77
|
|
78
|
+
it "should accept a format option" do
|
79
|
+
@processor.should_receive(:convert).with(@image, anything(), :png)
|
80
|
+
@processor.crop(@image, :width => '100', :height => '100', :format => :png)
|
81
|
+
end
|
82
|
+
|
78
83
|
it "should not crop if no args given" do
|
79
84
|
image = @processor.crop(@image)
|
80
85
|
image.should have_width(280)
|
@@ -132,17 +137,23 @@ describe ImageResizer::Processor do
|
|
132
137
|
end
|
133
138
|
|
134
139
|
|
135
|
-
describe "#resize(temp_object,
|
140
|
+
describe "#resize(temp_object, options)" do
|
141
|
+
|
136
142
|
context "when both the width and the height are non-zero" do
|
137
143
|
it "should crop and scale to the specified dimensions" do
|
138
|
-
@processor.should_receive(:resize_and_crop).with(@image, :width => 77, :height => 33, :gravity => 'c')
|
144
|
+
@processor.should_receive(:resize_and_crop).with(@image, hash_including(:width => 77, :height => 33, :gravity => 'c'))
|
139
145
|
@processor.resize(@image, :width => 77, :height => 33)
|
140
146
|
end
|
141
147
|
|
148
|
+
it "should accept a format option" do
|
149
|
+
@processor.should_receive(:resize_and_crop).with(@image, hash_including(:format => :png))
|
150
|
+
@processor.resize(@image, :width => 77, :height => 33, :format => :png)
|
151
|
+
end
|
152
|
+
|
142
153
|
context "with the crop_from_top_if_portrait option" do
|
143
154
|
context "with a portrait oriented image" do
|
144
155
|
it "should resize and crop with a gravity of 'n'" do
|
145
|
-
@processor.should_receive(:resize_and_crop).with(@image, :width => 77, :height => 33, :gravity => 'n')
|
156
|
+
@processor.should_receive(:resize_and_crop).with(@image, hash_including(:width => 77, :height => 33, :gravity => 'n'))
|
146
157
|
@processor.resize(@image, :width => 77, :height => 33, :crop_from_top_if_portrait => true)
|
147
158
|
end
|
148
159
|
end
|
@@ -150,7 +161,7 @@ describe ImageResizer::Processor do
|
|
150
161
|
context "with a landscape oriented image" do
|
151
162
|
it "should resize and crop with a gravity of 'c'" do
|
152
163
|
@image = ImageResizer::TempObject.new(SAMPLES_DIR.join('landscape.png')) # 355x280
|
153
|
-
@processor.should_receive(:resize_and_crop).with(@image, :width => 77, :height => 33, :gravity => 'c')
|
164
|
+
@processor.should_receive(:resize_and_crop).with(@image, hash_including(:width => 77, :height => 33, :gravity => 'c'))
|
154
165
|
@processor.resize(@image, :width => 77, :height => 33, :crop_from_top_if_portrait => true)
|
155
166
|
end
|
156
167
|
end
|
@@ -159,29 +170,44 @@ describe ImageResizer::Processor do
|
|
159
170
|
|
160
171
|
context "when the height is 0, nil, or not present" do
|
161
172
|
it "should restrict only in the horizontal dimension" do
|
162
|
-
@processor.should_receive(:_resize).with(@image, '77x').exactly(3).times
|
163
|
-
@processor.resize(@image, :width => 77, :height => 0)
|
173
|
+
@processor.should_receive(:_resize).with(@image, '77x', nil).exactly(3).times
|
174
|
+
@processor.resize(@image, :width => 77, :height => 0 )
|
164
175
|
@processor.resize(@image, :width => 77, :height => nil)
|
165
176
|
@processor.resize(@image, :width => 77)
|
166
177
|
end
|
178
|
+
|
179
|
+
it "should accept a format option" do
|
180
|
+
@processor.should_receive(:_resize).with(@image, '77x', :png)
|
181
|
+
@processor.resize(@image, :width => 77, :height => 0, :format => :png)
|
182
|
+
end
|
167
183
|
end
|
168
184
|
|
169
185
|
context "when the width is 0, nil, or not present" do
|
170
186
|
it "should restrict only in the vertical dimension" do
|
171
|
-
@processor.should_receive(:_resize).with(@image, 'x33').exactly(3).times
|
187
|
+
@processor.should_receive(:_resize).with(@image, 'x33', nil).exactly(3).times
|
172
188
|
@processor.resize(@image, :width => 0, :height => 33)
|
173
189
|
@processor.resize(@image, :width => nil, :height => 33)
|
174
190
|
@processor.resize(@image, :height => 33)
|
175
191
|
end
|
192
|
+
|
193
|
+
it "should accept a format option" do
|
194
|
+
@processor.should_receive(:_resize).with(@image, 'x33', :png)
|
195
|
+
@processor.resize(@image, :width => 0, :height => 33, :format => :png)
|
196
|
+
end
|
176
197
|
end
|
177
198
|
|
178
199
|
context "when both height and width are 0, nil, or not present" do
|
179
200
|
it "should return the original image file" do
|
180
|
-
@image.should_receive(:file).exactly(3).times
|
201
|
+
@image.should_receive(:file).exactly(3).times.and_return('the_file')
|
181
202
|
@processor.should_not_receive(:_resize)
|
182
|
-
@processor.resize(@image, :width => 0, :height => 0)
|
183
|
-
@processor.resize(@image, :width => nil, :height => nil)
|
184
|
-
@processor.resize(@image)
|
203
|
+
@processor.resize(@image, :width => 0, :height => 0).should == 'the_file'
|
204
|
+
@processor.resize(@image, :width => nil, :height => nil).should == 'the_file'
|
205
|
+
@processor.resize(@image).should == 'the_file'
|
206
|
+
end
|
207
|
+
|
208
|
+
it "should call convert with the target format" do
|
209
|
+
@processor.should_receive(:convert).with(@image, anything(), :png)
|
210
|
+
@processor.resize(@image, :width => 0, :height => 33, :format => :png)
|
185
211
|
end
|
186
212
|
end
|
187
213
|
end
|
@@ -189,15 +215,15 @@ describe ImageResizer::Processor do
|
|
189
215
|
|
190
216
|
|
191
217
|
|
192
|
-
describe "#resize_and_crop_around_point(:point => [x%, y%], :width => w, :height => h" do
|
218
|
+
describe "#resize_and_crop_around_point(:point => [x%, y%], :width => w, :height => h)" do
|
193
219
|
context "when the source image is portrait, but the requested ratio is landscape" do
|
194
220
|
it "should call crop_to_frame_and_resize with a frame that is vertically centered on the focus point" do
|
195
221
|
# original is 280px x 355px
|
196
222
|
@processor.should_receive(:crop_to_frame_and_resize ).with(@image,
|
197
|
-
:width => 100,
|
198
|
-
|
199
|
-
|
200
|
-
|
223
|
+
hash_including(:width => 100,
|
224
|
+
:height => 60,
|
225
|
+
:upper_left => [0.0, 0.5 - 280 * 0.6 / 355 / 2.0],
|
226
|
+
:lower_right => [1.0, 0.5 + 280 * 0.6 / 355 / 2.0]))
|
201
227
|
@processor.resize_and_crop_around_point(@image,
|
202
228
|
:point => [0.5, 0.5],
|
203
229
|
:width => 100,
|
@@ -205,14 +231,29 @@ describe ImageResizer::Processor do
|
|
205
231
|
)
|
206
232
|
end
|
207
233
|
|
234
|
+
it "should accept a format option" do
|
235
|
+
@processor.should_receive(:crop_to_frame_and_resize ).with(@image,
|
236
|
+
:width => 100,
|
237
|
+
:height => 60,
|
238
|
+
:upper_left => [0.0, 0.5 - 280 * 0.6 / 355 / 2.0],
|
239
|
+
:lower_right => [1.0, 0.5 + 280 * 0.6 / 355 / 2.0],
|
240
|
+
:format => :png)
|
241
|
+
@processor.resize_and_crop_around_point(@image,
|
242
|
+
:point => [0.5, 0.5],
|
243
|
+
:width => 100,
|
244
|
+
:height => 60,
|
245
|
+
:format => :png
|
246
|
+
)
|
247
|
+
end
|
248
|
+
|
208
249
|
context "when the focus point is too close to the top to be the vertical center" do
|
209
250
|
it "should call crop_to_frame_and_resize with a frame that is pinned at the top of the image" do
|
210
251
|
# original is 280px x 355px
|
211
252
|
@processor.should_receive(:crop_to_frame_and_resize ).with(@image,
|
212
|
-
:width => 100,
|
213
|
-
|
214
|
-
|
215
|
-
|
253
|
+
hash_including(:width => 100,
|
254
|
+
:height => 60,
|
255
|
+
:upper_left => [0.0, 0.0],
|
256
|
+
:lower_right => [1.0, 280 * 0.6 / 355]))
|
216
257
|
@processor.resize_and_crop_around_point(@image,
|
217
258
|
:point => [0.5, 0.1],
|
218
259
|
:width => 100,
|
@@ -225,10 +266,10 @@ describe ImageResizer::Processor do
|
|
225
266
|
it "should call crop_to_frame_and_resize with a frame that is pinned at the bottom of the image" do
|
226
267
|
# original is 280px x 355px
|
227
268
|
@processor.should_receive(:crop_to_frame_and_resize ).with(@image,
|
228
|
-
:width => 100,
|
229
|
-
|
230
|
-
|
231
|
-
|
269
|
+
hash_including(:width => 100,
|
270
|
+
:height => 60,
|
271
|
+
:upper_left => [0.0, 1 - 280 * 0.6 / 355],
|
272
|
+
:lower_right => [1.0, 1.0]))
|
232
273
|
@processor.resize_and_crop_around_point(@image,
|
233
274
|
:point => [0.5, 0.9],
|
234
275
|
:width => 100,
|
@@ -246,10 +287,10 @@ describe ImageResizer::Processor do
|
|
246
287
|
it "should call crop_to_frame_and_resize with a frame that is vertically centered on the focus point" do
|
247
288
|
# original is 355px x 280px
|
248
289
|
@processor.should_receive(:crop_to_frame_and_resize ).with(@image,
|
249
|
-
:width => 60,
|
250
|
-
|
251
|
-
|
252
|
-
|
290
|
+
hash_including(:width => 60,
|
291
|
+
:height => 100,
|
292
|
+
:upper_left => [0.5 - 280 * 0.6 / 355 / 2.0, 0.0],
|
293
|
+
:lower_right => [0.5 + 280 * 0.6 / 355 / 2.0, 1.0]))
|
253
294
|
@processor.resize_and_crop_around_point(@image,
|
254
295
|
:point => [0.5, 0.5],
|
255
296
|
:width => 60,
|
@@ -261,10 +302,10 @@ describe ImageResizer::Processor do
|
|
261
302
|
it "should call crop_to_frame_and_resize with a frame that is pinned at the left of the image" do
|
262
303
|
# original is 355px x 280px
|
263
304
|
@processor.should_receive(:crop_to_frame_and_resize ).with(@image,
|
264
|
-
:width => 60,
|
265
|
-
|
266
|
-
|
267
|
-
|
305
|
+
hash_including(:width => 60,
|
306
|
+
:height => 100,
|
307
|
+
:upper_left => [0.0, 0.0],
|
308
|
+
:lower_right => [280 * 0.6 / 355, 1.0]))
|
268
309
|
@processor.resize_and_crop_around_point(@image,
|
269
310
|
:point => [0.1, 0.5],
|
270
311
|
:width => 60,
|
@@ -277,10 +318,10 @@ describe ImageResizer::Processor do
|
|
277
318
|
it "should call crop_to_frame_and_resize with a frame that is pinned at the right of the image" do
|
278
319
|
# original is 355px x 280px
|
279
320
|
@processor.should_receive(:crop_to_frame_and_resize ).with(@image,
|
280
|
-
:width => 60,
|
281
|
-
|
282
|
-
|
283
|
-
|
321
|
+
hash_including(:width => 60,
|
322
|
+
:height => 100,
|
323
|
+
:upper_left => [1.0 - 280 * 0.6 / 355, 0.0],
|
324
|
+
:lower_right => [1.0, 1.0]))
|
284
325
|
@processor.resize_and_crop_around_point(@image,
|
285
326
|
:point => [0.9, 0.5],
|
286
327
|
:width => 60,
|
@@ -318,7 +359,7 @@ describe ImageResizer::Processor do
|
|
318
359
|
describe "#crop_to_frame_and_resize(:upper_left => [x%, y%], :lower_right => [x%, y%], :width => w, :height => h" do
|
319
360
|
it "should call #crop with the :x & :y and :width & :height expressed in pixels and :width and :height determined by the frame bounds (not the width and height we pass in), and :resize expressed as widthxheight" do
|
320
361
|
# original is 280px x 355px
|
321
|
-
@processor.should_receive(:convert).with(@image, "-crop 140x178+56+107 -resize 70x89 +repage")
|
362
|
+
@processor.should_receive(:convert).with(@image, "-crop 140x178+56+107 -resize 70x89 +repage", nil)
|
322
363
|
@processor.crop_to_frame_and_resize(@image,
|
323
364
|
:upper_left => [0.20, 0.30],
|
324
365
|
:lower_right => [0.70, 0.80],
|
@@ -327,10 +368,21 @@ describe ImageResizer::Processor do
|
|
327
368
|
)
|
328
369
|
end
|
329
370
|
|
371
|
+
it "should accept a format parameter" do
|
372
|
+
@processor.should_receive(:convert).with(@image, "-crop 140x178+56+107 -resize 70x89 +repage", :png)
|
373
|
+
@processor.crop_to_frame_and_resize(@image,
|
374
|
+
:upper_left => [0.20, 0.30],
|
375
|
+
:lower_right => [0.70, 0.80],
|
376
|
+
:width => 70,
|
377
|
+
:height => 89,
|
378
|
+
:format => :png
|
379
|
+
)
|
380
|
+
end
|
381
|
+
|
330
382
|
context "when width is 0, nil, or not present as an option" do
|
331
383
|
it "should use the ratio defined by the upper_left and lower_right points to determine the width from the height" do
|
332
384
|
# original is 280px x 355px
|
333
|
-
@processor.should_receive(:convert).with(@image, "-crop 140x178+56+107 -resize 70x89 +repage").exactly(3).times
|
385
|
+
@processor.should_receive(:convert).with(@image, "-crop 140x178+56+107 -resize 70x89 +repage", nil).exactly(3).times
|
334
386
|
@processor.crop_to_frame_and_resize(@image,
|
335
387
|
:upper_left => [0.20, 0.30],
|
336
388
|
:lower_right => [0.70, 0.80],
|
@@ -357,7 +409,7 @@ describe ImageResizer::Processor do
|
|
357
409
|
context "when height is 0, nil, or not present as an option" do
|
358
410
|
it "should use the ratio defined by the upper_left and lower_right points to determine the height from the width" do
|
359
411
|
# original is 280px x 355px
|
360
|
-
@processor.should_receive(:convert).with(@image, "-crop 140x178+56+107 -resize 70x89 +repage").exactly(3).times
|
412
|
+
@processor.should_receive(:convert).with(@image, "-crop 140x178+56+107 -resize 70x89 +repage", nil).exactly(3).times
|
361
413
|
@processor.crop_to_frame_and_resize(@image,
|
362
414
|
:upper_left => [0.20, 0.30],
|
363
415
|
:lower_right => [0.70, 0.80],
|
@@ -443,11 +495,18 @@ describe ImageResizer::Processor do
|
|
443
495
|
image.should have_height(355)
|
444
496
|
end
|
445
497
|
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
498
|
+
context "without a width and height option" do
|
499
|
+
it "should do nothing if called without width and height" do
|
500
|
+
image = @processor.resize_and_crop(@image)
|
501
|
+
image.should have_width(280)
|
502
|
+
image.should have_height(355)
|
503
|
+
image.should eq @image
|
504
|
+
end
|
505
|
+
|
506
|
+
it "should convert the image" do
|
507
|
+
@processor.should_receive(:convert).with(@image, '', :png)
|
508
|
+
@processor.resize_and_crop(@image, :format => :png)
|
509
|
+
end
|
451
510
|
end
|
452
511
|
|
453
512
|
it "should crop to the correct dimensions" do
|
@@ -456,6 +515,11 @@ describe ImageResizer::Processor do
|
|
456
515
|
image.should have_height(100)
|
457
516
|
end
|
458
517
|
|
518
|
+
it "should accept a format option" do
|
519
|
+
@processor.should_receive(:crop).with(@image, hash_including(:format => :png))
|
520
|
+
image = @processor.resize_and_crop(@image, :width => '100', :height => '100', :format => :png)
|
521
|
+
end
|
522
|
+
|
459
523
|
it "should actually resize before cropping" do
|
460
524
|
image1 = @processor.resize_and_crop(@image, :width => '100', :height => '100')
|
461
525
|
image2 = @processor.crop(@image, :width => '100', :height => '100', :gravity => 'c')
|
@@ -569,11 +633,10 @@ describe ImageResizer::Processor do
|
|
569
633
|
end
|
570
634
|
|
571
635
|
it "should allow for general convert commands with added format" do
|
572
|
-
image
|
636
|
+
image = @processor.convert(@image, '-scale 56x71', :gif)
|
573
637
|
image.should have_width(56)
|
574
638
|
image.should have_height(71)
|
575
639
|
image.should have_format('gif')
|
576
|
-
extra[:format].should == :gif
|
577
640
|
end
|
578
641
|
|
579
642
|
it "should work for commands with parenthesis" do
|
@@ -604,7 +667,7 @@ describe ImageResizer::Processor do
|
|
604
667
|
describe "#generate_icon" do
|
605
668
|
it "it should create a multi-sized ico file from the source file" do
|
606
669
|
two_fifty_six_png = double('256')
|
607
|
-
@processor.should_receive(:convert).with(@image, '-resize 256x256! -transparent white', :png).and_return(
|
670
|
+
@processor.should_receive(:convert).with(@image, '-resize 256x256! -transparent white', :png).and_return(two_fifty_six_png)
|
608
671
|
sixteen_png = double('16')
|
609
672
|
@processor.should_receive(:convert).with(two_fifty_six_png, '-resize 16x16! -transparent white').and_return(sixteen_png)
|
610
673
|
thirty_two_png = double('32')
|
@@ -616,19 +679,19 @@ describe ImageResizer::Processor do
|
|
616
679
|
|
617
680
|
ico = double('ico')
|
618
681
|
@processor.should_receive(:convert).with([sixteen_png, thirty_two_png, sixty_four_png, one_twenty_eight_png, two_fifty_six_png],
|
619
|
-
'', :ico).and_return(
|
682
|
+
'', :ico).and_return(ico)
|
620
683
|
@processor.generate_icon(@image)
|
621
684
|
end
|
622
685
|
|
623
686
|
it "it should accept a :max_resolution option to limit the number of formats" do
|
624
687
|
thirty_two_png = double('32')
|
625
|
-
@processor.should_receive(:convert).with(@image, '-resize 32x32! -transparent white', :png).and_return(
|
688
|
+
@processor.should_receive(:convert).with(@image, '-resize 32x32! -transparent white', :png).and_return(thirty_two_png)
|
626
689
|
sixteen_png = double('16')
|
627
690
|
@processor.should_receive(:convert).with(thirty_two_png, '-resize 16x16! -transparent white').and_return(sixteen_png)
|
628
691
|
|
629
692
|
ico = double('ico')
|
630
693
|
@processor.should_receive(:convert).with([sixteen_png, thirty_two_png],
|
631
|
-
'', :ico).and_return(
|
694
|
+
'', :ico).and_return(ico)
|
632
695
|
@processor.generate_icon(@image, :max_resolution => 32)
|
633
696
|
end
|
634
697
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_resizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &2157276080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2157276080
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: jeweler
|
27
|
-
requirement: &
|
27
|
+
requirement: &2157274360 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2157274360
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: pry
|
38
|
-
requirement: &
|
38
|
+
requirement: &2157300300 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2157300300
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: pry-nav
|
49
|
-
requirement: &
|
49
|
+
requirement: &2157299680 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2157299680
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: pry-stack_explorer
|
60
|
-
requirement: &
|
60
|
+
requirement: &2157298920 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2157298920
|
69
69
|
description: Image resizing gem (requires ImageMagick)
|
70
70
|
email: daniel@populr.me
|
71
71
|
executables: []
|
@@ -131,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
segments:
|
133
133
|
- 0
|
134
|
-
hash:
|
134
|
+
hash: -3748383720531710291
|
135
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
136
|
none: false
|
137
137
|
requirements:
|