|
323 | 323 | end |
324 | 324 | end |
325 | 325 |
|
326 | | - describe "#cover" do |
| 326 | + describe "#resize_to_cover" do |
327 | 327 | before do |
328 | 328 | @portrait_pipeline = ImageProcessing::Vips.source(@portrait) |
329 | 329 | @landscape_pipeline = ImageProcessing::Vips.source(@landscape) |
330 | 330 | @square_pipeline = ImageProcessing::Vips.source(@square) |
331 | 331 | end |
332 | 332 |
|
333 | 333 | it "resizes the portrait image to fill out the given landscape dimensions" do |
334 | | - assert_dimensions [300, 400], @portrait_pipeline.cover!(300, 200) |
| 334 | + assert_dimensions [300, 400], @portrait_pipeline.resize_to_cover!(300, 200) |
335 | 335 | end |
336 | 336 |
|
337 | 337 | it "resizes the portrait image to fill out the given portrait dimensions" do |
338 | | - assert_dimensions [225, 300], @portrait_pipeline.cover!(200, 300) |
| 338 | + assert_dimensions [225, 300], @portrait_pipeline.resize_to_cover!(200, 300) |
339 | 339 | end |
340 | 340 |
|
341 | 341 | it "resizes the portrait image to fill out the given square dimensions" do |
342 | | - assert_dimensions [300, 400], @portrait_pipeline.cover!(300, 300) |
| 342 | + assert_dimensions [300, 400], @portrait_pipeline.resize_to_cover!(300, 300) |
343 | 343 | end |
344 | 344 |
|
345 | 345 | it "resizes the landscape image to fill out the given portrait dimensions" do |
346 | | - assert_dimensions [400, 300], @landscape_pipeline.cover!(200, 300) |
| 346 | + assert_dimensions [400, 300], @landscape_pipeline.resize_to_cover!(200, 300) |
347 | 347 | end |
348 | 348 |
|
349 | 349 | it "resizes the landscape image to fill out the given landscape dimensions" do |
350 | | - assert_dimensions [300, 225], @landscape_pipeline.cover!(300, 200) |
| 350 | + assert_dimensions [300, 225], @landscape_pipeline.resize_to_cover!(300, 200) |
351 | 351 | end |
352 | 352 |
|
353 | 353 | it "resizes the landscape image to fill out the given square dimensions" do |
354 | | - assert_dimensions [400, 300], @landscape_pipeline.cover!(300, 300) |
| 354 | + assert_dimensions [400, 300], @landscape_pipeline.resize_to_cover!(300, 300) |
355 | 355 | end |
356 | 356 |
|
357 | 357 | it "resizes the square image to fill out the given portrait dimensions" do |
358 | | - assert_dimensions [300, 300], @square_pipeline.cover!(200, 300) |
| 358 | + assert_dimensions [300, 300], @square_pipeline.resize_to_cover!(200, 300) |
359 | 359 | end |
360 | 360 |
|
361 | 361 | it "resizes the square image to fill out the given landscape dimensions" do |
362 | | - assert_dimensions [300, 300], @square_pipeline.cover!(300, 200) |
| 362 | + assert_dimensions [300, 300], @square_pipeline.resize_to_cover!(300, 200) |
363 | 363 | end |
364 | 364 |
|
365 | 365 | it "resizes the square image to fill out the given square dimensions" do |
366 | | - assert_dimensions [300, 300], @square_pipeline.cover!(300, 300) |
| 366 | + assert_dimensions [300, 300], @square_pipeline.resize_to_cover!(300, 300) |
367 | 367 | end |
368 | 368 |
|
369 | 369 | it "produces correct image" do |
370 | 370 | expected = fixture_image("cover.jpg") |
371 | | - assert_similar expected, @portrait_pipeline.cover!(300, 200) |
| 371 | + assert_similar expected, @portrait_pipeline.resize_to_cover!(300, 200) |
372 | 372 | end |
373 | 373 |
|
374 | 374 | it "accepts thumbnail options except :crop" do |
375 | | - attention = @portrait_pipeline.cover!(400, 400, crop: :attention) |
376 | | - centre = @portrait_pipeline.cover!(400, 400, crop: :centre) |
| 375 | + attention = @portrait_pipeline.resize_to_cover!(400, 400, crop: :attention) |
| 376 | + centre = @portrait_pipeline.resize_to_cover!(400, 400, crop: :centre) |
377 | 377 | assert_similar centre, attention |
378 | 378 | end |
379 | 379 |
|
380 | 380 | it "accepts sharpening options" do |
381 | | - sharpened = @portrait_pipeline.cover!(400, 400, sharpen: ImageProcessing::Vips::Processor::SHARPEN_MASK) |
382 | | - normal = @portrait_pipeline.cover!(400, 400, sharpen: false) |
| 381 | + sharpened = @portrait_pipeline.resize_to_cover!(400, 400, sharpen: ImageProcessing::Vips::Processor::SHARPEN_MASK) |
| 382 | + normal = @portrait_pipeline.resize_to_cover!(400, 400, sharpen: false) |
383 | 383 | assert sharpened.size > normal.size, "Expected sharpened thumbnail to have bigger filesize than not sharpened thumbnail" |
384 | 384 | end |
385 | 385 |
|
386 | 386 | it "sharpening uses integer precision" do |
387 | | - sharpened = @portrait_pipeline.cover(400, 400).call(save: false) |
| 387 | + sharpened = @portrait_pipeline.resize_to_cover(400, 400).call(save: false) |
388 | 388 | assert_equal :uchar, sharpened.format |
389 | 389 | end |
390 | 390 | end |
|
0 commit comments