neofiles 2.0.2 → 2.0.3

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: 270d63f7c55f16dd7bc9899c7fe4f0c0ced9fbd3
4
- data.tar.gz: af060e4083f09b0493566075f3ea34d6d17f225b
3
+ metadata.gz: 3f6ec307c4477940ecef8bae9e9570b039f39d73
4
+ data.tar.gz: 521539112e2ba08f737ba2f5d607f7553ff701f8
5
5
  SHA512:
6
- metadata.gz: 4bca497d608747f6f563cf6421a816251157b9d4736ae88d021cd5f5718fcb7139288d2127e1cb328cf3045c06b5caf40634b83f79b088e7455496134de9b5a6
7
- data.tar.gz: 33a681aedf0cb58571f7cb97ca9fe90e3d51dc4e100adbd117d16f37640edca738f5ff75a30132d1fe0b5df36f6d49428028e18e0206488af3cf4cf67b8f814e
6
+ metadata.gz: 238f66b03f241411390c4093cc07e88c4a32147f5ac3863c7ae8f95715946717b11d9a465ed8d0db12fdc98723f23104caf969c9427d59a30d4998458a315ad1
7
+ data.tar.gz: a636696003ff1755839fde63650b788b2eedeeb0b97f0226a303d7f62260e87bd1235605db39e45051ffec498691f7d9df969f9ba8e8c21eeccf64f3ffb84021
@@ -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 = '2.0.2'
2
+ VERSION = '2.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neofiles
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konanykhin Ilya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-18 00:00:00.000000000 Z
11
+ date: 2018-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails