neofiles 1.2.1 → 1.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3a3e40bfe2629b65d69615621cbcdc37ab95e20
4
- data.tar.gz: 7f259aec163ff50fc5669735f4477e3c058cd942
3
+ metadata.gz: 5e933a90f0875b8daf85f331a22fb6625f671dbb
4
+ data.tar.gz: 73851322957bfc79951825f9b2f588e0bec9875b
5
5
  SHA512:
6
- metadata.gz: 3f6faca2b60cb0d6cb706ba969d729b2b25146a8eaeaad7dc937e72aa74a5fa2119ff424f27660b477d1eacca2a716b5e2c59bd9d0b36fc0c6c30fed7433cb47
7
- data.tar.gz: 63bb20c3acf34a8e337bb9097454577c46d045de915f5948c810cbb9f38b45c225d08b027d945dbba73ec3dbde29ccff1216cf4769c604ac6e586e614570176d
6
+ metadata.gz: b593c8017570ccca9615a6ca2820b2a3181f8e7fb79fdcffc090d0c684e38f078e6484017937603c06643bf7fd2ddeb8c0c3ad4ea05a78a96b9e5cc551705679
7
+ data.tar.gz: 1cdb3f6e73c224040a4cb1f36db92fd4cf13e4b35e47dba8db8efa95252ff724e1c88c2502cbab41e19979482556876c6d86666021688d55113bf13f145d77a7
data/lib/neofiles.rb CHANGED
@@ -57,6 +57,19 @@ module Neofiles
57
57
  # image fits into requested dimensions, no resizing will occur
58
58
  return image_file_width, image_file_height if image_file_width <= width && image_file_height <= height
59
59
 
60
+ in_aspect = 1.0 * image_file_width / image_file_height
61
+ out_aspect = 1.0 * width / height
62
+
63
+ if in_aspect > out_aspect
64
+ # If image is more "flat", the output width will always be equal to the requested width,
65
+ # and the output height will be less than the requested height
66
+ height = nil
67
+ else
68
+ # If input image is more "stretched" vertically or its aspect ratio is equal to output aspect ratio,
69
+ # the output height will be equal to the requested height, and the output width will be less than or equal to the requested width
70
+ width = nil
71
+ end
72
+
60
73
  AspectRatio.resize(image_file_width, image_file_height, width, height).map(&:to_i)
61
74
 
62
75
  rescue
@@ -1,3 +1,3 @@
1
1
  module Neofiles
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neofiles
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konanykhin Ilya